Minggu, 04 Desember 2011

Latihan 3 - Rumah Makan Serba Ayam - Visual Basic

Buat Desain Seperti ini :






dan masukan script dibawah ini sesuai procedurenya :

'text1 --> Total Tagihan
'text2-text5 (berurut ke bawah) --> Harga Perporsi - Total Biaya Minuman
'option1-option3 --> Ayam Bakar - Ayam Panggang
'check1 -> Es Kelapa , check2-> Es Buah
Private Sub Check1_Click()
If Check1.Value = 1 And Check2.Value = 1 Then
Text5.Text = "12500"
ElseIf Check1.Value = 0 And Check2.Value = 0 Then
Text5.Text = "0"
ElseIf Check1.Value = 0 And Check2.Value = 1 Then
Text5.Text = "7500"
ElseIf Check1.Value = 1 And Check2.Value = 0 Then
Text5.Text = "5000"
End If
End Sub

Private Sub Check2_Click()
If Check1.Value = 1 And Check2.Value = 1 Then
Text5.Text = "12500"
ElseIf Check1.Value = 0 And Check2.Value = 0 Then
Text5.Text = "0"
ElseIf Check1.Value = 0 And Check2.Value = 1 Then
Text5.Text = "7500"
ElseIf Check1.Value = 1 And Check2.Value = 0 Then
Text5.Text = "5000"
End If
End Sub

Private Sub Command1_Click()
If Command1.Caption = "Data Baru" Then
Option1.Enabled = True
Option2.Enabled = True
Option3.Enabled = True
Check1.Enabled = True
Check2.Enabled = True
Text3.Enabled = True
Text1.Text = "0"
Text2.Text = "0"
Text3.Text = "0"
Text4.Text = "0"
Text5.Text = "0"
Option1.Value = False
Option2.Value = False
Option3.Value = False
Check1.Value = 0
Check2.Value = 0
Option1.SetFocus
Command1.Caption = "Hitung Tagihan"
ElseIf Command1.Caption = "Hitung Tagihan" Then
If Option1.Value = False And Option2.Value = False And Option3.Value = False Then
    MsgBox "Harap Pilih Jenis Makanan", , "Konfirmasi Makanan"
    Option1.SetFocus
ElseIf Text3.Text = "" Or Text3.Text = "0" Then
    MsgBox "Harap Isi Berapa banyak Porsi makanan", , "Konfirmasi Porsi"
    Text3.SetFocus
Else
Text1.Text = Val(Text4.Text) + Val(Text5.Text)
Command1.Caption = "Data Baru"
Option1.Enabled = False
Option2.Enabled = False
Option3.Enabled = False
Check1.Enabled = False
Check2.Enabled = False
Text3.Enabled = False
End If
End If
End Sub

Private Sub Form_Load()
Option1.Enabled = False
Option2.Enabled = False
Option3.Enabled = False
Check1.Enabled = False
Check2.Enabled = False
Text3.Enabled = False
Text1.Text = "0"
Text2.Text = "0"
Text3.Text = "0"
Text4.Text = "0"
Text5.Text = "0"
End Sub

Private Sub Option1_Click()
If Option1.Value = True Then
Text2.Text = "15000"
Else
Text2.Text = ""
End If
End Sub

Private Sub Option1_GotFocus()
If Option1.Value = True Then
Text2.Text = "15000"
Else
Text2.Text = ""
End If
End Sub
Private Sub Option2_Click()
If Option2.Value = True Then
Text2.Text = "10000"
Else
Text2.Text = ""
End If
End Sub
Private Sub Option3_Click()
If Option3.Value = True Then
Text2.Text = "20000"
Else
Text2.Text = ""
End If
End Sub

Private Sub Text2_Change()
Text4.Text = Val(Text2.Text) * Val(Text3.Text)
End Sub

Private Sub Text3_Change()
Text4.Text = Val(Text2.Text) * Val(Text3.Text)
End Sub

Private Sub Text3_GotFocus()
Text3.Text = ""
End Sub

1 komentar: