Jumat, 13 Desember 2013

Cara Menggunakan Case

Public Class Form1

    Private Sub Proses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Proses.Click
        th.Text = jb.Text * h.Text
    End Sub

    Private Sub kb_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb.SelectedIndexChanged
        Dim x As String
        Dim a As String
        a = Microsoft.VisualBasic.Right(kb.Text, 3)
        x = Microsoft.VisualBasic.Left(kb.Text, 2)
        Select Case x
            Case "TS"
                m.Text = "Toshiba"
                Select Case a
                    Case "001"
                        nb.Text = "Falshdisk 1GB"
                        h.Text = "10500"
                    Case "002"
                        nb.Text = "Flashdisk 2GB"
                        h.Text = "7500"
                End Select
            Case "VG"
                m.Text = "V-Gen"
                Select Case a
                    Case "001"
                        nb.Text = "Falshdisk 4GB"
                        h.Text = "9000"
                    Case "002"
                        nb.Text = "Flashdisk 8GB"
                        h.Text = "6000"
                End Select
            Case "KG"
                m.Text = "Kingston"
                Select Case a
                    Case "001"
                        nb.Text = "Falshdisk 12GB"
                        h.Text = "90000"
                    Case "002"
                        nb.Text = "Flashdisk 16GB"
                        h.Text = "120000"
                End Select
        End Select
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        kb.Items.Add("TS001")
        kb.Items.Add("TS002")
        kb.Items.Add("VG001")
        kb.Items.Add("VG002")
        kb.Items.Add("KG001")
        kb.Items.Add("KG002")
    End Sub

    Private Sub hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus.Click
        Call clear()
    End Sub
    Sub clear()
        no.Text = ""
        kb.Text = ""
        nb.Text = ""
        h.Text = ""
        jb.Text = ""
        m.Text = ""
        th.Text = ""
        no.Focus()
    End Sub

    Private Sub Keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Keluar.Click
        Dim i As MsgBoxResult
        i = MsgBox("Apa anda keluar dari program ini?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Daftar distribusi barang PT. Sejahtera")
        If i = MsgBoxResult.Yes Then
            Close()
        End If
    End Sub
End Class

Tidak ada komentar:

Posting Komentar