Lab 4:Write a Visual Basic Program for Vending Mechine
Private Sub Command1_Click()
If Option1.Value = True Then
MsgBox ("Your Bill is " & Label2.Caption * Val(Text1.Text) & ".")
ElseIf Option2.Value = True Then
MsgBox ("Your Bill is " & Label3.Caption * Val(Text1.Text) & ".")
ElseIf Option3.Value = True Then
MsgBox ("Your Bill is " & Label4.Caption * Val(Text1.Text) & ".")
Else: MsgBox ("Your Bill is " & Label5.Caption * Val(Text1.Text) & ".")
End If
End Sub
Private Sub Command2_Click()
If Option1.Value = True Then
Label7.Caption = "Biscuit"
ElseIf Option2.Value = True Then
Label7.Caption = "Chips"
ElseIf Option3.Value = True Then
Label7.Caption = "chocolate"
Else
Label7.Caption = "Juice"
End If
End Sub
If Option1.Value = True Then
MsgBox ("Your Bill is " & Label2.Caption * Val(Text1.Text) & ".")
ElseIf Option2.Value = True Then
MsgBox ("Your Bill is " & Label3.Caption * Val(Text1.Text) & ".")
ElseIf Option3.Value = True Then
MsgBox ("Your Bill is " & Label4.Caption * Val(Text1.Text) & ".")
Else: MsgBox ("Your Bill is " & Label5.Caption * Val(Text1.Text) & ".")
End If
End Sub
Private Sub Command2_Click()
If Option1.Value = True Then
Label7.Caption = "Biscuit"
ElseIf Option2.Value = True Then
Label7.Caption = "Chips"
ElseIf Option3.Value = True Then
Label7.Caption = "chocolate"
Else
Label7.Caption = "Juice"
End If
End Sub
Leave a Comment