Tugas Teori 4 | Array Dimensi 1 (Kasus 1)
Awesome Image

Kasus 1 

 

Public Class Form4
    'Naufal Farisi Zamzam
    '2017230092
    Dim ArrayProv() As String = {"Jawa Barat", "Banten", "Jawa Tengah"}
    Dim ArrayKotaJabar() As String = {"Bandung", "Cimahi", "Cirebon"}
    Dim ArrayKotaBanten() As String = {"Cilegon", "Serang"}
    Dim ArrayKotaJateng() As String = {"Brebes", "Semarang"}
    Dim ArrayKecBandung() As String = {"Antapani", "Babakanciparay"}
    Dim ArrayKecCimahi() As String = {"Cimahi Utara", "Cimahi Tengah"}
    Dim ArrayKecCilegon() As String = {"Cibeber", "Gerogol"}
    Dim ArrayKecSerang() As String = {"Curug", "Kasemen"}
    Dim ArrayKecBrebes() As String = {"Losari", "Salem"}
    Dim ArrayKecSemarang() As String = {"Banyumanik", "Mijen"}
    Dim ArrayKecKaliMekar() As String = {"kalipasung", "kalimekar"}

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.SelectedIndex = 0 Then
            ComboBox2.Items.Clear()
            ComboBox2.Items.AddRange(ArrayKotaJabar)
        ElseIf ComboBox1.SelectedIndex = 1 Then
            ComboBox2.Items.Clear()
            ComboBox2.Items.AddRange(ArrayKotaBanten)
        ElseIf ComboBox1.SelectedIndex = 2 Then
            ComboBox2.Items.Clear()
            ComboBox2.Items.AddRange(ArrayKotaJateng)
        End If
    End Sub

    Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ComboBox1.Items.AddRange(ArrayProv)
    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        If ComboBox2.SelectedItem = "Bandung" Then
            ComboBox3.Items.Clear()
            ComboBox3.Items.AddRange(ArrayKecBandung)
        ElseIf ComboBox2.SelectedItem = "Cimahi" Then
            ComboBox3.Items.Clear()
            ComboBox3.Items.AddRange(ArrayKecCimahi)
        ElseIf ComboBox2.SelectedItem = "Cilegon" Then
            ComboBox3.Items.Clear()
            ComboBox3.Items.AddRange(ArrayKecCilegon)
        ElseIf ComboBox2.SelectedItem = "Serang" Then
            ComboBox3.Items.Clear()
            ComboBox3.Items.AddRange(ArrayKecSerang)
        ElseIf ComboBox2.SelectedItem = "Cirebon" Then
            ComboBox3.Items.Clear()
            ComboBox3.Items.AddRange(ArrayKecKaliMekar)
        ElseIf ComboBox2.SelectedItem = "Semarang" Then
            ComboBox3.Items.Clear()
            ComboBox3.Items.AddRange(ArrayKecSemarang)

        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If ComboBox1.SelectedItem = "" Then
            MsgBox("belum pilih provinsi")
        ElseIf ComboBox2.SelectedItem = "" Then
            MsgBox("belum pilih kota")
        ElseIf ComboBox2.SelectedItem = "" Then
            MsgBox("belum pilih kecamatan")
        Else
            lstTampil.Items.Clear()
            lstTampil.Items.Add("Provinsi yang dipilih " + ComboBox1.SelectedItem)
            lstTampil.Items.Add("Kota yang dipilih " + ComboBox2.SelectedItem)
            lstTampil.Items.Add("Kecamatan yang dipilih " + ComboBox3.SelectedItem)
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        lstTampil.Items.Clear()

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Me.Text = "Naufal Farisi Zamzam"
        Dim pesan As String
        pesan = MsgBox("Yakin mau keluar??", vbYesNo, "naufalfz.my.id")
        If pesan = vbYes Then
            End
        End If
    End Sub
End Class