Sunday, October 30, 2011

Nested IF Quis ( VB )


Terms of problem : 


kode montir kode motor biaya

WWN                   SZK 50000
(Wewen)                HND       55000
                            YMH 60000

BDI                        SZK       60000
(Budi) HND 65000
                            YMH 70000



When the form is active then the textbox code mechanic, motor code, name of the mechanic, service prices, oil prices, total prices and money back in an inactive state.

At the click "Hitung" will pay out the total value.

When the input of money paid and the press enter then the money returned.

At the click "Input Lagi" then all net textbox.

To make a timer using two labels and a timer in the properties
Change the name of the label 1 = jam
And label 2 = tanggal
Click 2x on a timer and enter the listing:

jam.caption = time
Tanggal.caption = format (date, "dddd, d mmmm, yyyy")


on the properties of the timer, change interval = 100


this is the listing :




Private Sub cck1_Click()
If cck1 = 1 And cck2 = 1 Then
    txtservis = 80000
ElseIf cck1 = 1 Then
    txtservis = 30000
ElseIf cck2 = 1 Then
    txtservis = 50000
Else
    txtservis = 0
End If
End Sub

Private Sub cck2_Click()
If cck1 = 1 And cck2 = 1 Then
    txtservis = 80000
ElseIf cck1 = 1 Then
    txtservis = 30000
ElseIf cck2 = 1 Then
    txtservis = 50000
Else
    txtservis = 0
End If
End Sub

Private Sub Ckomon_Click()
If Ckomon.Text = "WWN" Then
    txtnamon = "Wewen"
Else
    txtnamon = "Budi"
End If
End Sub


Private Sub Ckotor_Click()
If Ckotor.Text = "SZK" Then
    txtjenis = "Suzuki"
    If Ckomon.Text = "WWN" Then
        txtbiaya = 50000
    Else
        txtbiaya = 60000
    End If
ElseIf Ckotor.Text = "HND" Then
    txtjenis = "Honda"
    If Ckomon.Text = "WWN" Then
        txtbiaya = 55000
    Else
        txtbiaya = 65000
    End If
Else
    txtjenis = "Yamaha"
    If Ckomon.Text = "WWN" Then
        txtbiaya = 60000
    Else
        txtbiaya = 70000
    End If
End If
End Sub

Private Sub Cmdhitung_Click()
txttotbay = Val(txtbiaya) + Val(txtservis) + Val(txtoli)
txtubay.SetFocus
End Sub

Private Sub cmdinput_Click()
txtnama = ""
Ckomon = "-PiliH-"
Ckotor = "-PiliH-"
txtnamon = ""
txtjenis = ""
txtbiaya = ""
cck1 = False
cck2 = False
txtservis = ""
optganti = False
opttidak = False
txtoli = ""
txttotbay = ""
txtubay = ""
txtukem = ""
End Sub

Private Sub cmdkeluar_Click()
If MsgBox("Yakin lo mau Keluar ??", 36, "WArning") = vbYes Then
End
End If
End Sub

Private Sub Form_Load()
txtnamon.Enabled = False
txtjenis.Enabled = False
txtbiaya.Enabled = False
txtservis.Enabled = False
txtoli.Enabled = False
txttotbay.Enabled = False
txtukem.Enabled = False
End Sub

Private Sub optganti_Click()
txtoli = 30000
Cmdhitung.SetFocus
End Sub

Private Sub opttidak_Click()
txtoli = 0
Cmdhitung.SetFocus
End Sub

Private Sub Timer1_Timer()
jam.Caption = Time
tanggal.Caption = Format(Date, "dddd, d ,mmmm, yyyy")
End Sub


Private Sub txtubay_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    txtukem = Val(txtubay) - Val(txttotbay)
    cmdinput.SetFocus
End If
End Sub


Enjoy it... ^_^
If anyone does not understand please ask and leave a comment ..
and do not forget to follow our blog ..^_^

No comments:

Post a Comment