Friday 5 April 2013

Form Latihan Pertemuann 3 VB1 (Percabangan)


Tampilan form

Private Sub cmbbaru_Click()
cmbjenis.Text = "--Pilih--"
txtharga.Text = ""
txtjumbel.Text = ""
txttotal.Text = ""
txtubay.Text = ""
txtukem.Text = ""
optl.Value = False
optm.Value = False
opts.Value = False
End Sub

Private Sub cmbkeluar_Click()
z = MsgBox("Are you sure want to exit?", vbQuestion + vbOKCancel, "Keluar")
If z = vbOK Then
End
End If
End Sub

Private Sub Form_Load()
cmbjenis.AddItem "KAOS"
cmbjenis.AddItem "CELANA"
End Sub

Private Sub opts_Click()
If cmbjenis.Text = "KAOS" Then
txtharga.Text = 35000
Else
txtharga.Text = 50000
End If
End Sub
Private Sub optm_Click()
If cmbjenis.Text = "KAOS" Then
txtharga.Text = 40000
Else
txtharga.Text = 55000
End If
End Sub
Private Sub optl_Click()
If cmbjenis.Text = "KAOS" Then
txtharga.Text = 45000
Else
txtharga.Text = 60000
End If
End Sub

Private Sub txtjumbel_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txttotal = Val(txtharga.Text) * Val(txtjumbel.Text)
txtubay.SetFocus
End If
End Sub

Private Sub txtubay_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtukem = Val(txtubay.Text) - Val(txttotal.Text)
cmbbaru.SetFocus
End If
End Sub

Related Articles

0 comments:

Post a Comment