follow me =)

Selasa, 27 Mac 2012

menu KFC dan McD


Hari ini aku suka pula hendak tulis blog mengenai apa yang aku belajar.. Pada sesiapa yang sudah mahir tentang Visual Basic (VB) mesti tidak heran kot tapi yang penting aku teruja hendak buat VB ini hehehe.. Memang tidak dinafikan dalam internet terlalu banyak coding dan tunjuk ajar yang diberikan tapi aku tetap suka dengan pengetahuan aku yang ada ini... Masih banyak lagi coding yang aku tidak tahu dan masih banyak lagi yang perlu aku belajar dan mahirkan.. 

Ok. Sekarang aku guna Microsoft Visual Studio 2008 untuk buat Windows Application dalam 4 form seperti di bawah ini...
form1 : klik samada KFC or McD
form2 : menu KFC 
form3 : Menu McD
form4 : Resit keluar
Ok. Ini pula coding dia...

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form2.Show()
        Me.Hide()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Form3.Show()
        Me.Hide()
    End Sub
End Class

****************

Public Class Form2

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.CheckState = 1 Then
            ComboBox1.Enabled = True
        End If
        If CheckBox1.CheckState = 0 Then
            ComboBox1.Enabled = False
        End If
    End Sub

    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        If CheckBox2.CheckState = 1 Then
            ComboBox2.Enabled = True
        End If
        If CheckBox2.CheckState = 0 Then
            ComboBox2.Enabled = False
        End If
    End Sub

    Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
        If CheckBox3.CheckState = 1 Then
            ComboBox3.Enabled = True
        End If
        If CheckBox3.CheckState = 0 Then
            ComboBox3.Enabled = False
        End If
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged

    End Sub

    Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a, b, c, resulta, resultb, resultc, sum As Double
        a = ComboBox1.SelectedItem
        b = ComboBox2.SelectedItem
        c = ComboBox3.SelectedItem
        resulta = a * 8.65
        resultb = b * 10.55
        resultc = c * 10.25
        sum = resulta + resultb + resultc
        TextBox9.Text = "RM " & sum
    End Sub

    Private Sub TextBox9_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Form4.Show()
        Me.Hide()
        Form4.TextBox1.Text = TextBox9.Text
    End Sub
End Class

*********************

Public Class Form3

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.CheckState = 1 Then
            ComboBox1.Enabled = True
        End If
        If CheckBox1.CheckState = 0 Then
            ComboBox1.Enabled = False
        End If
    End Sub

    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        If CheckBox2.CheckState = 1 Then
            ComboBox2.Enabled = True
        End If
        If CheckBox2.CheckState = 0 Then
            ComboBox2.Enabled = False
        End If
    End Sub

    Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
        If CheckBox3.CheckState = 1 Then
            ComboBox3.Enabled = True
        End If
        If CheckBox3.CheckState = 0 Then
            ComboBox3.Enabled = False
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a, b, c, aa, bb, cc, sum As Double
        a = ComboBox1.SelectedItem
        b = ComboBox2.SelectedItem
        c = ComboBox3.SelectedItem
        aa = a * 10.95
        bb = b * 9.9
        cc = c * 4.6
        sum = aa + bb + cc
        TextBox9.Text = "RM " & sum
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Form4.Show()
        Me.Hide()
        Form4.TextBox1.Text = TextBox9.Text
    End Sub
End Class

**********************

Public Class Form4

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        End
    End Sub
End Class


Ok..Itu sahaja yang dapat dikongsikan bersama... Esok aku akan upload coding calcultor pula.. =)...

p/s : Selamat Mencuba!!! =)

1 ulasan:

  1. tgk benda ni teringat final projek degree aku...guna vb gak...lama gile dah tinggal benda ni...hehe

    BalasPadam