Contoh Pemrograman Visual (Visual Basic) dengan menggunakan List dan Structure Select .. Case versi saya :)
-----------------------------------------------------------------
Codingan
Private Sub Command1_Click()
Dim harga As Currency, total As Currency
Dim jumlah As Integer
Dim disc As Single
Dim satuan As String
If Text1.Text = "" Or Text1.Text = " "
Then
MsgBox "Anda Belum Memilih Barang dan atau Memasukkan
Jumlah!!"
List1.ListIndex = 0
Exit Sub
End If
Select Case List1.Text
Case "Flashdisk"
harga = 120000
satuan = "pack"
Case "Modem"
harga = 300000
satuan = "pack"
Case "PC"
harga = 5000000
satuan = "set"
Case "Laptop"
harga = 10000000
satuan = "buah"
Case "Kertas"
harga = 3000
satuan = "rim"
End Select
Label2.Caption = "Barang : " & List1.Text
Label3.Caption = "Harga : " & Format(harga,
"currency") & "/" & satuan
jumlah = Text1.Text
Select Case jumlah
Case Is < 10
disc = 0
Case 10 To 20
disc = 0.15
Case Else
disc = 0.2
End Select
Label4.Caption = "Jumlah : " & jumlah &
" " & satuan
total = jumlah * (harga * (1 - disc))
Label5.Caption = "Discount : " & Format(disc,
"0%")
Label6.Caption = "Total Bayar : " &
Format(total, "currency")
End Sub
Private Sub Command2_Click()
Label2.Caption = ""
Label3.Caption = ""
Label4.Caption = ""
Label5.Caption = ""
Label6.Caption = ""
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Command3_Click()
MsgBox "Transaksi Selesai .. Terima Kasih.. "
End
End Sub
Private Sub Form_Load()
List1.AddItem "Flashdisk"
List1.AddItem "Modem"
List1.AddItem "PC"
List1.AddItem "Laptop"
List1.AddItem "Kertas"
End Sub
Private Sub List1_Click()
End Sub
Private Sub Text1_Change()
If Not IsNumeric(Text1.Text) Then
MsgBox "Masukkan Angka Pada Jumlah!"
Text1.Text = ""
End If
End Sub
Private Sub Timer1_Timer()
Label8 = Time
End Sub
No comments:
Post a Comment