Script Latihan VB Pertemuan 3 (Percabangan)
Tampilan form
Private Sub cjabatan_Click()
If cjabatan.Text = "Direktur" Then
txtgapok.Text = 3500000
ElseIf cjabatan.Text = "Manager" Then
txtgapok.Text = 2500000
Else
txtgapok.Text = 1500000
End If
End Sub
Private Sub cmbbersih_Click()
txtgaber.Text = "0"
txtgapok.Text = "0"
txtnama.Text = ""
txtnip.Text = ""
txttunjangan.Text = "0"
cjabatan.Text = "--Pilih--"
cjk.Text = "--Pilih--"
optbelum.Value = False
optmenikah.Value = False
End Sub
Private Sub cmbhitung_Click()
txtgaber = Val(txtgapok.Text) + Val(txttunjangan.Text)
End Sub
Private Sub cmbkeluar_Click()
Unload Me
End Sub
Private Sub Form_Load()
cjk.AddItem "Laki-Laki"
cjk.AddItem "Perempuan"
cjabatan.AddItem "Direktur"
cjabatan.AddItem "Manager"
cjabatan.AddItem "Supervisior"
optbelum.Value = False
optmenikah.Value = False
End Sub
Private Sub optbelum_Click()
If optbelum.Value = True Then
txttunjangan.Text = Val(txtgapok.Text) * 0.1
Else
txttunjangan.Text = 0
End If
End Sub
Private Sub optmenikah_Click()
If optmenikah.Value = True Then
txttunjangan = Val(txtgapok.Text) * 0.15
Else
txttunjangan.Text = 0
End If
End Sub
0 comments:
Post a Comment