Latihan_UTS VB

Buat tampilan sebagai berikut :

vb1.jpg


Private Sub ch1_Click()
If ch1 = 1 And ch2 = 0 Then
txttunj.Text = 10 / 100 * Val(txtgapok.Text)
Else
If ch1 = 0 And ch2 = 1 Then
txttunj.Text = 5 / 100 * Val(txtgapok.Text)
Else
If ch1 = 1 And ch2 = 1 Then
txttunj.Text = 15 / 100 * Val(txtgapok.Text)
Else
txttunj.Text = 0
End If
End If
End If
End Sub

Private Sub ch2_Click()
If ch1 = 1 And ch2 = 0 Then
txttunj.Text = 10 / 100 * Val(txtgapok.Text)
Else
If ch1 = 0 And ch2 = 1 Then
txttunj.Text = 5 / 100 * Val(txtgapok.Text)
Else
If ch1 = 1 And ch2 = 1 Then
txttunj.Text = 15 / 100 * Val(txtgapok.Text)
Else
txttunj.Text = 0
End If
End If
End If
End Sub

Private Sub cmdhitung_Click()
txttotal.Text = Val(txtgapok.Text) + Val(txttunj.Text)
End Sub

Private Sub bersih()
Dim x As Control
For Each x In Me
If TypeName(x) = “TextBox” Then
x.Text = “”
End If
Next
ch1 = o
ch2 = 0
End Sub

Private Sub cmdinput_Click()
bersih
tampil
txtnip.SetFocus
End Sub

Private Sub Form_Load()
sembunyi
End Sub

Private Sub txtnip_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Left(txtnip, 4) = “2005” Then
txtthn.Text = “2005”
Else
If Left(txtnip, 4) = “2006” Then
txtthn.Text = “2006”
Else
If Left(txtnip, 4) = “2007” Then
txtthn.Text = “2007”
Else
MsgBox “Tahun Masuk Tidak Ada”, vbOKOnly, “Info”
bersih
sembunyi
End If
End If
End If
If Mid(txtnip, 5, 2) = “01” Then
txtjbtn.Text = “Direktur”
txtgapok.Text = 1500000
Else
If Mid(txtnip, 5, 2) = “02” Then
txtjbtn.Text = “Staff”
txtgapok.Text = 1000000
Else
If Mid(txtnip, 5, 2) = “03” Then
txtjbtn.Text = “umum”
txtgapok.Text = 850000
Else
bersih
sembunyi
End If
End If
End If
End If
End Sub

Private Sub sembunyi()
txtnip.Visible = False
Label2.Visible = False
End Sub

Private Sub tampil()
txtnip.Visible = True
Label2.Visible = True
End Sub

Silakan Anda Modifikasi lagi untuk belajar …..

Iklan

3 Comments

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