Selasa, 27 Desember 2011

CONTOH SOAL VB SEDERHANA


PENJUALAN MOTOR HONDA
Data yang di input : Nama Consumen
                                 Tanggal pembelian
                                 Merk barang
                                 Jenis barang
                                 -jika  jenis barang  “revo cw” maka
                                Harga barang = 11.400.000
                                -jika jenis barang  “revo tecno at” maka
                                Harga barang = 13.200.000
                                -jika jenis barang  “supra x 125 cw” maka
                                Harga barang = 15.500.000
                                -jika jenis barang “supra x 125 helm-in” maka
                                Harga barang = 15..600.000
                                -jika jenis barang “blade repsol” maka
                                Harga barang = 14.200.000
                                 -jika jenis barang “beat cw” maka
                                 Harga barang = 12.550.000
                                 -jika jenis barang “scoopy” maka
                                 Harga barang = 13.725.000
                                 -jika jenis barang “cs1” maka
                                 Harga barang = 17.275.000
                                 -jika jenis barang “mega pro” maka
                                 Harga barang = 19.500.000
                                 -jika jenis barang “ tiger” maka
                                 Harga barang = 25.000.000
                                 -jika jenis barang “cbr” maka
                                 Harga barang = 33.000.000

Ketentuan : nama barang dan jenis barang menggunakan(Combo box ).
                   Tanggal pembeli menggunakan (microsoft windows common control-26.0)
Data yang di proses : Jumlah barang
                                  Harga kotor =  harga barang  *  jumlah barang
                                  Pembelian (cash/credit) menggunakan combo box
                                  Ketentuan Diskon tergantung dari pembelian cash/credit
                                  -jika pembelian “cash” maka
                                   Diskonnya 4% dari harga kotor
                                  -if pembelian “credit” maka
                                   Diskonnya 0 dari harga kotor
                                  Total =  harag kotor – diskon
PENYELESAIANNYA:
Private Sub Combo1_Click()
If Combo1 = "REVO CW" Then
    Text3 = 11400000
    Else
If Combo1 = "REVO TECNO AT" Then
    Text3 = 13200000
    Else
If Combo1 = "SUPRA X 125 CW" Then
    Text3 = 15500000
    Else
If Combo1 = "SUPRA X 125 HELM-IN" Then
    Text3 = 15600000
    Else
If Combo1 = "BLADE REPSOL" Then
    Text3 = 14200000
    Else
If Combo1 = "BEAT CW" Then
    Text3 = 12550000
    Else
If Combo1 = "SCOOPY" Then
    Text3 = 13725000
    Else
If Combo1 = "CS1" Then
    Text3 = 17275000
    Else
If Combo1 = "MEGA PRO" Then
    Text3 = 19500000
    Else
If Combo1 = "TIGER" Then
    Text3 = 25000000
    Else
    Text3 = 33000000
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If


End Sub

Private Sub Combo2_Click()
If Combo2 = "CASH" Then
    Text6 = 0.03 * Val(Text5)
    Else
    Text6 = 0
End If
Text7 = Val(Text5) - Val(Text6)

End Sub
Private Sub Form_click()
Text1 = Clear
Text3 = Clear
Text4 = Clear
Text5 = Clear
Text6 = Clear
Text7 = Clear
End Sub

Private Sub Label1_Click()
Text1.Locked = True
Text3.Locked = True
Text4.Locked = True
Text5.Locked = True
Text6.Locked = True
Text7.Locked = True
Combo1.Locked = True
Combo2.Locked = True
Combo3.Locked = True
End Sub

Private Sub Label2_Click()
Text1.Locked = False
Text3.Locked = False
Text4.Locked = False
Text5.Locked = False
Text6.Locked = False
Text7.Locked = False
Combo1.Locked = False
Combo2.Locked = False
Combo3.Locked = False
End Sub

Private Sub Text4_Change()
Text5 = Val(Text4) * Val(Text3)

End Sub


Private Sub Timer1_Timer()
Label12.Caption = Format(Now(), "hh:mm:ss")
Form1.BackColor = RGB(Rnd * 225, Rnd * 225, Rnd * 225)
End Sub

0 komentar:

Poskan Komentar