Gambar Design Programnya :
Tombol yang kita gunakan adalah :
Label = 12 buah
Combobox = 1 buah
texbox = 1 buah
command button = 3 buah
Sebelum memasukkan coding, Ubah terlebih dahulu pada caption dan name nya, caranya ada pada postingan sebelumnya.
Dan ini Codingnya:
Private Sub cbobarang_Click()
x = cbobarang
If x = "MN" Then
Lbnamabarang.Caption = "Monitor"
ElseIf x = "KY" Then
Lbnamabarang.Caption = "Kyboard"
ElseIf x = "MS" Then
Lbnamabarang.Caption = "Mouse"
Else
Lbnamabarang.Caption = "Cooling"
End If
a = cbobarang
If a = "MN" Then
lbhargasatuan.Caption = 800000
ElseIf a = "KY" Then
lbhargasatuan.Caption = 45000
ElseIf a = "MS" Then
lbhargasatuan.Caption = 40000
Else
lbhargasatuan.Caption = 35000
End If
End Sub
Private Sub Command1_Click()
lbtotalharga.Caption = txtjmlbeli.Text * lbhargasatuan
If Lbnamabarang.Caption = "Monitor" And txtjmlbeli.Text >= 10 Then
lbpotonganharga.Caption = lbtotalharga.Caption * 2 / 100
ElseIf Lbnamabarang.Caption = "Kyboard" And txtjmlbeli.Text >= 10 Then
lbpotonganharga.Caption = lbtotalharga.Caption * 1 / 100
Else
lbpotonganharga.Caption = lbtotalharga.Caption * 0
End If
lbtotalbayar.Caption = lbtotalharga.Caption - lbpotonganharga.Caption
End Sub
Private Sub Command2_Click()
With cbobarang
.Clear
.AddItem "MN"
.AddItem "KY"
.AddItem "MS"
.AddItem "CL"
End With
txtjmlbeli.Text = ""
lbhargasatuan.Caption = ""
Lbnamabarang.Caption = ""
lbpotonganharga.Caption = ""
lbtotalbayar.Caption = ""
lbtotalharga.Caption = ""
cbobarang.SetFocus
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
With cbobarang
.Clear
.AddItem "MN"
.AddItem "KY"
.AddItem "MS"
.AddItem "CL"
End With
txtjmlbeli.Text = ""
lbhargasatuan.Caption = ""
Lbnamabarang.Caption = ""
lbpotonganharga.Caption = ""
lbtotalbayar.Caption = ""
lbtotalharga.Caption = ""
End Sub
x = cbobarang
If x = "MN" Then
Lbnamabarang.Caption = "Monitor"
ElseIf x = "KY" Then
Lbnamabarang.Caption = "Kyboard"
ElseIf x = "MS" Then
Lbnamabarang.Caption = "Mouse"
Else
Lbnamabarang.Caption = "Cooling"
End If
a = cbobarang
If a = "MN" Then
lbhargasatuan.Caption = 800000
ElseIf a = "KY" Then
lbhargasatuan.Caption = 45000
ElseIf a = "MS" Then
lbhargasatuan.Caption = 40000
Else
lbhargasatuan.Caption = 35000
End If
End Sub
Private Sub Command1_Click()
lbtotalharga.Caption = txtjmlbeli.Text * lbhargasatuan
If Lbnamabarang.Caption = "Monitor" And txtjmlbeli.Text >= 10 Then
lbpotonganharga.Caption = lbtotalharga.Caption * 2 / 100
ElseIf Lbnamabarang.Caption = "Kyboard" And txtjmlbeli.Text >= 10 Then
lbpotonganharga.Caption = lbtotalharga.Caption * 1 / 100
Else
lbpotonganharga.Caption = lbtotalharga.Caption * 0
End If
lbtotalbayar.Caption = lbtotalharga.Caption - lbpotonganharga.Caption
End Sub
Private Sub Command2_Click()
With cbobarang
.Clear
.AddItem "MN"
.AddItem "KY"
.AddItem "MS"
.AddItem "CL"
End With
txtjmlbeli.Text = ""
lbhargasatuan.Caption = ""
Lbnamabarang.Caption = ""
lbpotonganharga.Caption = ""
lbtotalbayar.Caption = ""
lbtotalharga.Caption = ""
cbobarang.SetFocus
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
With cbobarang
.Clear
.AddItem "MN"
.AddItem "KY"
.AddItem "MS"
.AddItem "CL"
End With
txtjmlbeli.Text = ""
lbhargasatuan.Caption = ""
Lbnamabarang.Caption = ""
lbpotonganharga.Caption = ""
lbtotalbayar.Caption = ""
lbtotalharga.Caption = ""
End Sub
Semoga Bermanfaat.