Pemakaian SELECT CASE (2) Pada Visual Basic Net
Nancy Popo
November 29, 2013
0 Comments
Di bawah ini merupakan contoh pemakaian Select Case (2) pada visual basic net.
Berikut program pemakaian select case menggunakan Visual Basic Net.
Public Class Form1
Private Sub Label3_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Label3.Click
End Sub
Private Sub Kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles
Kode.SelectedIndexChanged
Dim x As String
x =
Microsoft.VisualBasic.Left(Kode.Text, 2)
If x = "TS" Then
merk.Text = "Toshiba"
ElseIf
x = "VG" Then
merk.Text = "V-Gen"
End If
x =
Microsoft.VisualBasic.Right(Kode.Text, 3)
If x = "001" Then
Namabarang.Text = "Flashdisk 4Gb"
ElseIf
x = "002" Then
Namabarang.Text = "Flashdisk 2Gb"
End If
End Sub
Private Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Kode.Items.Add("TS001")
Kode.Items.Add("TS002")
Kode.Items.Add("VG001")
Kode.Items.Add("VG002")
End Sub
End Class
Dan Hasilnya seperti dibawah ini :