Pert.4 Brancing Visual Basic 6.0

Brancing yang akan saya paparkan disini yaitu :
1. If…Else
Bu : If (kondisi-1 ) then
pernyataan-1
else
If (kondisi-2) then
pernyataan-2
else
pernyataan-n
endif
endif
2. Select Case
Bu : Select Case (pilihan/variabel)
case nilai
pernyataan-1
case nilai
pernyataan-2
case nilai
pernyataan-n
end select


Buatlah Tampilan Sebagai berikut :
vb1.JPG

Listing yang dapat anda gunakan :
Private Sub Form_Load()
Combo1.AddItem “ADS”
Combo1.AddItem “SPC”
Combo1.AddItem “RBX”
End Sub

Private Sub cmdbersih_Click()
Combo1.Text = “Pilih Kode”
txtnm.Text = “”
txthrg.Text = “0”
txtjumbel.Text = “”
txttotbay.Text = “0”
txtbonus.Text = “”
txtubay.Text = “”
txtukem.Text = “0”
End Sub

Private Sub Combo1_Click()
Select Case (Combo1.Text)
Case “ADS”
txtnm.Text = “Adidas”
txthrg.Text = 155000
Case “SPC”
txtnm.Text = “Spotec”
txthrg.Text = 200000
Case “RBX”
txtnm.Text = “ReeBox”
txthrg.Text = 250000
End Select
txtjumbel.SetFocus
End Sub

Private Sub cmdhitung_Click()
txttotbay.Text = Val(txtjumbel.Text) * txthrg.Text
If (txtjumbel.Text >= 2) Then
txtbonus.Text = “Yoyo Magic”
Else
txtbonus.Text = “Maaf lom Dapet”
End If
txtubay.SetFocus
End Sub

Private Sub txtubay_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtukem.Text = Val(txtubay.Text) – Val(txttotbay.Text)
End If
End Sub

Private Sub cmdkeluar_Click()
p = MsgBox(“Anda Ingin Keluar ??”, vbOKCancel + vbInformation, “Info”)
If p = vbOK Then
Unload Me
End If
End Sub

ms.JPG

Selamat Mencoba…..

Iklan

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s