Senin, 10 April 2017

Tugas Enable Disable


KODINGNYA :

Public Class Form1
    Dim tawar, isi, kering As String
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Label1.Text = "Atas Nama :"
        Label2.Text = "Minuman Pendamping :"
        Button1.Text = "OK"
        Button2.Text = "Pesan"
        Button3.Text = "Hapus salah satu Menu"
        Button4.Text = "Hapus Semua Menu"
        CheckBox1.Text = "Roti Tawar"
        CheckBox2.Text = "Roti Isi"
        CheckBox3.Text = "Roti Kering"

        With Me.ComboBox1
            .Items.Add("Kopi")
            .Items.Add("Teh")
            .Items.Add("Ice Cream")
        End With

        With Me.ComboBox3
            .Items.Add("Original")
            .Items.Add("Gandum")
            .Items.Add("Pandan")
            .Items.Add("Kismis")
        End With

        With Me.ComboBox4
            .Items.Add("Roti isi Keju")
            .Items.Add("Roti isi Blueberry")
            .Items.Add("Roti isi Strawberry")
            .Items.Add("Roti isi Cokelat")
        End With

        With Me.ComboBox5
            .Items.Add("Semprit")
            .Items.Add("Nastar")
            .Items.Add("Kastengel")
            .Items.Add("Putri Salju")
        End With

        ComboBox1.Enabled = False
        ComboBox3.Enabled = False
        ComboBox4.Enabled = False
        ComboBox5.Enabled = False

        If CheckBox1.Checked = True Then
            ComboBox3.Enabled = True
        Else
            ComboBox3.Enabled = False
        End If

        If CheckBox2.Checked = True Then
            ComboBox4.Enabled = True
        Else
            ComboBox4.Enabled = False
        End If

        If CheckBox3.Checked = True Then
            ComboBox5.Enabled = True
        Else
            ComboBox5.Enabled = False
        End If
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MsgBox("Anda ingin menambahkan Minuman Pendamping")
        ComboBox1.Enabled = True
    End Sub

    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
        ComboBox3.Enabled = True
    End Sub

    Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.CheckedChanged
        ComboBox4.Enabled = True
    End Sub

    Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox3.CheckedChanged
        ComboBox5.Enabled = True
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        If CheckBox1.Checked = True Then
            tawar = "Tawar"
        Else : tawar = ""
        End If

        If CheckBox2.Checked = True Then
            isi = "Isi"
        Else : isi = ""
        End If

        If CheckBox3.Checked = True Then
            kering = "Kering"
        Else : kering = ""
        End If
        ListBox1.Items.Add("Atas Nama :" & TextBox1.Text)
        ListBox1.Items.Add("Minuman Pendamping :" & ComboBox1.Text)
        ListBox1.Items.Add(tawar)
        ListBox1.Items.Add(ComboBox3.Text)
        ListBox1.Items.Add(isi)
        ListBox1.Items.Add(ComboBox4.Text)
        ListBox1.Items.Add(kering)
        ListBox1.Items.Add(ComboBox5.Text)

    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        MsgBox("Anda akan Menghapus salah satu menu pesanan")
        ListBox1.Items.Remove(ListBox1.SelectedItem)
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        MsgBox("Anda akan menghapus semua menu pesanan")
        ListBox1.Items.Clear()
    End Sub

    Private Sub GroupBox1_Enter(sender As Object, e As EventArgs) Handles GroupBox1.Enter

    End Sub
End Class


0 komentar:

Posting Komentar