Jumat, 13 April 2012

TAMPILAN DAN LISTING TUGAS PRA UTS2
























Listing Tugas VB Pra UTS 2 ( PENGINAPAN)

Private Sub cmbkode_Click()
If cmbkode.Text = "SU01" Then
txtjenis.Text = "Suite"
ElseIf cmbkode.Text = "BS01" Then
txtjenis.Text = "Business"
Else
txtjenis.Text = "President"
End If
End Sub

Sub aktif() 
txtnama.Enabled = True
cmbkode.Enabled = True
opt1.Enabled = True
opt2.Enabled = True
opt3.Enabled = True
txtlama.Enabled = True
txtubay.Enabled = True
End Sub

Sub nonaktif()
txtnama.Enabled = False
txttgl.Enabled = False
cmbkode.Enabled = False
txtjenis.Enabled = False
opt1.Enabled = False
opt2.Enabled = False
opt3.Enabled = False
txtharga.Enabled = False
txtlama.Enabled = False
txttotal.Enabled = False
txtubay.Enabled = False
txtukem.Enabled = False
End Sub

Sub bersih()
txtnama.Text = ""
cmbkode.Text = ""
txtjenis.Text = ""
opt1.Value = 0
opt2.Value = 0
opt3.Value = 0
txtharga.Text = ""
txtlama.Text = ""
txttotal.Text = ""
txtubay.Text = ""
txtukem.Text = ""
End Sub

Private Sub cmdisidata_Click()
bersih
aktif
cmbkode.Text = "-Pilih-"
txtnama.SetFocus
End Sub

Private Sub cmdkeluar_Click()
X = MsgBox("TutupForm?",vbYesNo + vbQuestion, "Konfirmasi")
If X = vbYes Then
Unload Me
End If
End Sub

Private Sub Form_Activate()
bersih
nonaktif
txttgl.Text = Date
cmbkode.AddItem "SU01"
cmbkode.AddItem "BS01"
cmbkode.AddItem "PR01"
cmdisidata.Enabled = True
cmdkeluar.Enabled = True
End Sub

Private Sub opt1_Click()
If opt1.Value = True Then
If txtjenis.Text = "Suite" Then
txtharga.Text = 300000
ElseIf txtjenis.Text = "Business" 
Then
txtharga.Text = 400000
Else
txtharga.Text = 500000
End If
Else
txtharga.Text = 0
End If
txtlama.SetFocus
End Sub

Private Sub opt2_Click()
If opt2.Value = True Then
If txtjenis.Text = "Suite" Then
txtharga.Text = 500000
ElseIf txtjenis.Text = "Business" Then
txtharga.Text = 600000
Else
txtharga.Text = 700000
End If
Else
txtharga.Text = 0
End If
txtlama.SetFocus
End Sub

Private Sub opt3_Click()
If opt3.Value = True Then
If txtjenis.Text = "Suite" Then
txtharga.Text = 800000
ElseIf txtjenis.Text = "Business" Then
txtharga.Text = 900000
Else
txtharga.Text = 1000000
End If
Else
txtharga.Text = 0
End If
txtlama.SetFocus
End Sub


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

Private Sub txtubay_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
a = Val(txttotal.Text) - Val(txtubay.Text)
If txtubay.Text < txttotal.Text  Then
MsgBox "Uang Anda Kurang RP." & Val(txttotal.Text) - Val(txtubay.Text) & " 
Input Uang Kembali", vbOKOnly, "Warning!"
txtubay.Text = ""
txtubay.SetFocus
Else
txtukem.Text = Val(txtubay.Text) - Val(txttotal.Text)
End If
End If
End Sub

Tidak ada komentar:

Posting Komentar