Kamis, 19 April 2012

Tugas Pra UTS 2


Tugas Pra UTS 2
Tampilan Awal
 LISTINGNYA............................
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
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
txttgl.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 Form_Activate()
nonaktif
bersih
txttgl.Text = Date
cmbkode.AddItem "SU01"
cmbkode.AddItem "BS01"
cmbkode.AddItem "PR01"
cmdisi.Enabled = True
cmdkeluar.Enabled = True
End Sub

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

Private Sub cmdisi_Click()
aktif
bersih
txtnama.SetFocus
cmbkode.Text = "-Pilih-"
cmdisi.Enabled = True
cmdkeluar.Enabled = True
End Sub

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

Private Sub opt1_Click()
If opt1.Value = True And txtjenis.Text = "Suit" Then
txtharga.Text = 300000
ElseIf opt1.Value = True And txtjenis.Text = "Bussines" Then
txtharga.Text = 500000
Else
txtharga.Text = 800000
End If
txtlama.SetFocus
End Sub

Private Sub opt2_Click()
If opt2.Value = True And txtjenis.Text = "Suit" Then
txtharga.Text = 400000
ElseIf opt2.Value = True And txtjenis.Text = "Bussines" Then
txtharga.Text = 600000
Else
txtharga.Text = 900000
End If
txtlama.SetFocus
End Sub

Private Sub opt3_Click()
If opt3.Value = True And txtjenis.Text = "Suit" Then
txtharga.Text = 500000
ElseIf opt3.Value = True And txtjenis.Text = "Bussines" Then
txtharga.Text = 7000000
Else
txtharga.Text = 1000000
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)
End If
End Sub

Private Sub txttotal_Change()
txtubay.SetFocus
End Sub

Private Sub txtubay_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    Val (txttotal.Text) - Val(txtubay.Text)
If txtubay.Text < txttotal.Text Then
MsgBox "Maaf Uang Anda Kurang Rp. " & (Val(txttotal.Text) - Val(txtubay.Text)) & "," & "Silahkan Input Kembali", vbOKOnly + vbInformation, "Informasi"
txtubay.Text = ""
txtubay.SetFocus
txtukem.Text = ""
Else
txtukem.Text = Val(txtubay.Text) - Val(txttotal.Text)
End If
cmdisi.Enabled = True
End If
End Sub

Private Sub txtukem_Change()
If Val(txtukem.Text) < 0 Then
txtukem.Enabled = "False"
End If
End Sub

Saat di Input
Saat tombol input di klik lagi

Saat uang bayar kurang


Saat uang bayar di isi kembali

Saat tombol keluar di klik




 

Tidak ada komentar:

Posting Komentar