“Cafe Yunfa” dengan Visual Basic 6.0
Percontohan “Cafe Yunfa” yang terdapat pada blog “Fitri Meliana”.
Sedikit modifikasi yang dibuat, sekedar untuk menghindari kesalahan pada saat pemasukan data yang bernilai lebih dari satu. Untuk lebih lengkapnya dapat dilihat pada kode sumber yang disertakan.
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Cafe ""YUNFA"""
ClientHeight = 5430
ClientLeft = 45
ClientTop = 405
ClientWidth = 9015
BeginProperty Font
Name = "Segoe UI"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5430
ScaleWidth = 9015
StartUpPosition = 2 'CenterScreen
Begin MSComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 375
Left = 0
TabIndex = 28
Top = 5055
Visible = 0 'False
Width = 9015
_ExtentX = 15901
_ExtentY = 661
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 1
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
End
Begin VB.CommandButton Command1
Caption = "Keluar"
Height = 495
Index = 1
Left = 7320
TabIndex = 27
Top = 4800
Width = 1575
End
Begin VB.CommandButton Command1
Caption = "Proses"
Height = 495
Index = 0
Left = 6480
TabIndex = 26
Top = 3720
Width = 2295
End
Begin VB.TextBox Text1
Height = 375
Index = 6
Left = 6480
TabIndex = 25
Top = 3120
Width = 2295
End
Begin VB.TextBox Text1
Height = 375
Index = 5
Left = 6480
TabIndex = 23
Top = 2280
Width = 2295
End
Begin VB.TextBox Text1
Height = 375
Index = 4
Left = 6480
TabIndex = 21
Top = 1440
Width = 2295
End
Begin VB.TextBox Text1
Height = 375
Index = 3
Left = 6480
TabIndex = 19
Top = 600
Width = 2295
End
Begin VB.Frame Frame2
Caption = "Jenis Pemesanan:"
Height = 2055
Left = 3360
TabIndex = 12
Top = 2400
Width = 2895
Begin VB.TextBox Text1
Height = 375
Index = 2
Left = 1080
Locked = -1 'True
TabIndex = 16
TabStop = 0 'False
Top = 1440
Width = 1575
End
Begin VB.PictureBox Picture1
BorderStyle = 0 'None
Height = 1095
Left = 120
ScaleHeight = 1095
ScaleWidth = 2295
TabIndex = 13
Top = 240
Width = 2295
Begin VB.OptionButton Option1
Caption = "Makan di Tempat"
Height = 495
Index = 1
Left = 120
TabIndex = 15
Top = 600
Width = 1935
End
Begin VB.OptionButton Option1
Caption = "Pesan Antar"
Height = 495
Index = 0
Left = 120
TabIndex = 14
Top = 120
Width = 1455
End
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Harga:"
Height = 255
Index = 3
Left = 285
TabIndex = 17
Top = 1485
Width = 585
End
End
Begin VB.Frame Frame1
Caption = "Daftar Makanan:"
Height = 4215
Index = 0
Left = 240
TabIndex = 0
Top = 240
Width = 2895
Begin VB.ComboBox Combo1
Height = 375
Index = 0
Left = 240
TabIndex = 1
Text = "Pilih Menu..."
Top = 360
Width = 2415
End
Begin VB.ComboBox Combo1
Height = 375
Index = 1
Left = 240
TabIndex = 2
Text = "Pilih Paket..."
Top = 840
Width = 2415
End
Begin VB.ListBox List1
Height = 1845
Left = 240
TabIndex = 4
TabStop = 0 'False
Top = 1620
Width = 2415
End
Begin VB.TextBox Text1
Height = 375
Index = 0
Left = 1080
Locked = -1 'True
TabIndex = 6
TabStop = 0 'False
Top = 3645
Width = 1575
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "List Menu:"
Height = 255
Index = 0
Left = 260
TabIndex = 3
Top = 1320
Width = 885
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Harga:"
Height = 255
Index = 1
Left = 285
TabIndex = 5
Top = 3675
Width = 585
End
End
Begin VB.Frame Frame1
Caption = "Daftar Minuman:"
Height = 1935
Index = 1
Left = 3360
TabIndex = 7
Top = 240
Width = 2895
Begin VB.CheckBox Check1
Caption = "Dingin"
Height = 375
Left = 255
TabIndex = 9
Top = 840
Width = 960
End
Begin VB.TextBox Text1
Height = 375
Index = 1
Left = 1035
Locked = -1 'True
TabIndex = 11
TabStop = 0 'False
Top = 1320
Width = 1575
End
Begin VB.ComboBox Combo1
Height = 375
Index = 2
Left = 240
TabIndex = 8
Text = "Pilih Minuman..."
Top = 360
Width = 2415
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Harga:"
Height = 255
Index = 2
Left = 285
TabIndex = 10
Top = 1365
Width = 585
End
End
Begin VB.Line Line1
Index = 0
X1 = 0
X2 = 9240
Y1 = 4680
Y2 = 4680
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Uang Kembalian:"
Height = 255
Index = 7
Left = 6480
TabIndex = 24
Top = 2760
Width = 1485
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Uang Pembayaran:"
Height = 255
Index = 6
Left = 6480
TabIndex = 22
Top = 1920
Width = 1650
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Total Pembayaran:"
Height = 255
Index = 5
Left = 6480
TabIndex = 20
Top = 1080
Width = 1620
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Jumlah Pembelian:"
Height = 255
Index = 4
Left = 6480
TabIndex = 18
Top = 240
Width = 1605
End
Begin VB.Line Line1
BorderColor = &H00FFFFFF&
BorderWidth = 4
Index = 1
X1 = 0
X2 = 9240
Y1 = 4680
Y2 = 4680
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Harga_Makanan, Harga_Minuman, Harga_Pesanan As Integer
Dim Total_Pembelian As Double
Private Sub Check1_Click()
If Check1.Value = 0 Then
Harga_Minuman = Harga_Minuman - 1000
Else
Harga_Minuman = Harga_Minuman + 1000
End If
Text1(1).Text = Format(Harga_Minuman, "Currency")
End Sub
Private Sub Combo1_Click(Index As Integer)
Select Case Index
Case 0:
With Combo1(1)
.Clear
.Text = "Pilih Paket..."
.AddItem "Paket 1"
.AddItem "Paket 2"
End With
List1.Clear
Text1(Index).Text = Empty
Case 1:
If Combo1(0).Text = "Sarapan Pagi" Then
Select Case Combo1(Index).Text
Case "Paket 1"
With List1
.Clear
.AddItem "Nasi Uduk"
.AddItem "Telur"
.AddItem "Tempe Orek"
End With
Harga_Makanan = 8000
Case "Paket 2"
With List1
.Clear
.AddItem "Nasi Goreng"
.AddItem "Telur Mata Sapi"
.AddItem "Tempe Goreng"
End With
Harga_Makanan = 10000
End Select
Text1(0).Text = Format(Harga_Makanan, "Currency")
Else
Select Case Combo1(Index).Text
Case "Paket 1"
With List1
.Clear
.AddItem "Nasi Putih"
.AddItem "Ayam Bakar"
.AddItem "Lalapan"
End With
Harga_Makanan = 12000
Case "Paket 2"
With List1
.Clear
.AddItem "Nasi Putih"
.AddItem "Rendang"
.AddItem "Sayur"
.AddItem "Sambal Ijo"
End With
Harga_Makanan = 19000
End Select
Text1(0).Text = Format(Harga_Makanan, "Currency")
End If
Case 2:
Select Case Combo1(Index).Text
Case "Air Mineral"
Harga_Minuman = 2000
Case "Air Jeruk"
Harga_Minuman = 4500
Case "Teh Manis"
Harga_Minuman = 3500
End Select
Text1(1).Text = Format(Harga_Minuman, "Currency")
End Select
End Sub
Private Sub Combo1_KeyPress(Index As Integer, KeyAscii As Integer)
If (KeyAscii = 13) Then
SendKeys "{tab}"
KeyAscii = 0
End If
End Sub
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0:
Dim Uang_Pembayaran, Uang_Kembalian As Double
If Command1(Index).Caption = "Proses" Then
Uang_Pembayaran = Text1(5).Text
Uang_Kembalian = Uang_Pembayaran - Total_Pembelian
Text1(6).Text = Format(Uang_Kembalian, "Currency")
Command1(Index).Caption = "Baru"
Else
Dim i%
For i = 0 To 2
Combo1(i).Clear
Next
List1.Clear
Text1(0).Text = Empty
Text1(2).Text = Empty
Text1(3).Text = 0
Text1(5).Text = 0
Text1(4).Text = Empty
Text1(6).Text = Empty
Text1(1).Text = Empty
'Check1.Value = 0
For i = 0 To 1
Option1(i).Value = False
Next
Form_Load
Combo1(0).Text = "Pilih Menu..."
Combo1(1).Text = "Pilih Paket..."
Combo1(2).Text = "Pilih Minuman..."
Command1(Index).Caption = "Proses"
Combo1(0).SetFocus
End If
Case 1:
Unload Me
End Select
End Sub
Private Sub Form_Load()
With Combo1(0)
.AddItem "Sarapan Pagi"
.AddItem "Makan Biasa"
End With
With Combo1(1)
.AddItem "Paket 1"
.AddItem "Paket 2"
End With
With Combo1(2)
.AddItem "Air Mineral"
.AddItem "Air Jeruk"
.AddItem "Teh Manis"
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Keluar program ?", vbQuestion + vbYesNo, "Perhatian") = vbNo Then
Cancel = 1
Combo1(0).SetFocus
End If
End Sub
Private Sub Option1_Click(Index As Integer)
If Option1(0).Value = True Then
Harga_Pesanan = 5000
Else
Harga_Pesanan = 2000
End If
Text1(2).Text = Format(Harga_Pesanan, "Currency")
Text1(3).SetFocus
End Sub
Private Sub Text1_Change(Index As Integer)
Dim Jumlah_Pembelian, Jumlah_Sementara As Integer
Select Case Index
Case 3:
Jumlah_Pembelian = Text1(Index).Text
Jumlah_Sementara = Harga_Makanan + Harga_Minuman + Harga_Pesanan
Total_Pembelian = Jumlah_Sementara * Jumlah_Pembelian
Text1(4).Text = Format(Total_Pembelian, "Currency")
Text1(5).SetFocus
End Select
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or _
KeyAscii = 13 Or KeyAscii = vbKeyBack) Then
Beep
KeyAscii = 0
End If
Select Case Index
Case 5:
If (KeyAscii = 13) Then
Command1_Click (0)
Command1(0).SetFocus
End If
End Select
End Sub
Unduh Kode Sumber
Label: VB6
0 Komentar:
Posting Komentar
Berlangganan Posting Komentar [Atom]
<< Beranda