DESCRIPTION : food menu sample program below is how the structure of the "select case" is used in Visual Basic 6.0,
“Open VB 6.0, Copy paste source code and save project program is runing “
Private Sub Form_Load()
List1.AddItem "Mie Ayam"
List1.AddItem "Mie Goreng"
List1.AddItem "Cumi Goreng"
List1.AddItem "Tempe"
End Sub
Private Sub Command1_Click()
Dim Harga As Currency, Total As Currency
Dim jumlah As Integer
Dim Diskon As Single
Dim satuan As String
If List1.Text = "" Then
MsgBox "Anda belum memilih barang !!"
List1.ListIndex = 0
Exit Sub
End If
If Text1.Text = "" Then
MsgBox "Anda belum mengisi jumlah barang !!"
Text1.SetFocus
Exit Sub
End If
If Not IsNumeric(Text1.Text) Then
MsgBox "Isi jumlah barang harus angka !!"
Text1.SetFocus
Exit Sub
End If
Select Case List1.Text
Case "Tempe"
Harga = 35000
satuan = "Porsi"
Case "Mie Ayam"
Harga = 20000
satuan = "Porsi"
Case "Mie Goreng"
Harga = 25000
satuan = "Porsi"
Case "Cumi Goreng"
Harga = 10000
satuan = "Porsi"
End Select
lblBarang.Caption = "Barang : " & List1.Text
lblHarga.Caption = "Harga : " & Format(Harga, "Currency") & "/" & satuan
lblJumlah.Caption = "Jumlah : " & Text1.Text & " " & satuan
jumlah = Text1.Text
Select Case jumlah
Case Is < 10
Diskon = 0
Case 10 To 20
Diskon = 0.15
Case Else
Diskon = 0.2
End Select
Total = jumlah * (Harga * (1 - Diskon))
lblDiskon.Caption = "Diskon : " & Format(Diskon, "0 %")
lblTotal.Caption = "Total Bayar : " & Format(Total, "Currency")
End Sub
0 comments:
Post a Comment