Rem 總體變數的宣告,需放在 <物件欄為ㄧ般> ,<程序欄為 宣告 > 內才有作用 Dim n As Integer '-----------------------------------------------------
Private Sub Form_Load ( ) Rem 班級: 學號: 姓名: Rem ***** 點餐系統之計算程式 ***** REm Rem 設定 Combo1 內容 Combo1.AddItem "紅茶" Combo1.AddItem "咖啡" Combo1.AddItem "啤酒" Rem 設定 Combo2 內容 Combo2.AddItem "豬排" Combo2.AddItem "魚排" Combo2.AddItem "牛排" Rem 設定 Combo3 內容 Combo3.AddItem "牛肉麵" Combo3.AddItem "排骨麵" Combo3.AddItem "水餃" End Sub '-----------------------------------------------------
Private Sub Combo1_Click( ) Rem 設定 Combo1 內 Index之值 If Combo1.ListIndex = "0" Then Label8.Caption = "25元" ElseIf Combo1.ListIndex = "1" Then Label8.Caption = "35元" ElseIf Combo1.ListIndex = "2" Then Label8.Caption = "40元" End If End Sub '-----------------------------------------------------
Private Sub Combo2_click( ) Rem 設定 Combo2 內 Index之值 If Combo2.ListIndex = 0 Then Label9.Caption = "70元" ElseIf Combo2.ListIndex = 1 Then Label9.Caption = "90元" ElseIf Combo2.ListIndex = 2 Then Label9.Caption = "120元" End If End Sub '-----------------------------------------------------
Private Sub Combo3_Click( ) Rem 設定 Combo3內 Index之值 If Combo3.ListIndex = 0 Then Label10.Caption = "70元" ElseIf Combo3.ListIndex = 1 Then Label10.Caption = "50元" ElseIf Combo3.ListIndex = 2 Then Label10.Caption = "4元/粒" End If End Sub '-----------------------------------------------------
Private Sub Command1_Click( ) Rem 帳單計算 Sum = 0 Sum = Sum + (Val(Label8) * Val(Text1)) + (Val(Label9) * Val(Text2)) + (Val(Label10) * Val(Text3)) Label12.Caption = Sum If Option1.Value = True Then Label15.Caption = Sum ElseIf Option2.Value = True Then Label15.Caption = Sum * (1 + 0.05) ElseIf Option3.Value = True Then Label15.Caption = Sum * 0.8 End If End Sub '-----------------------------------------------------