Dim num As Integer, i As Integer, s As Single, n As Single, p As Integer '定义
Private Sub Check1_Click(Index As Integer) ‘单机check控件组
If Check1(Index).Value = 1 Then ’如果显示选上
Text1(Index).Enabled = True ’相对应的text可以输入文字
Text1(Index).SetFocus ‘并且得到焦点
Else ’否则
Text1(Index).Text = "" ‘相对应的text显示为空
Text1(Index).Enabled = False ‘不可输入文字
End If
End Sub
Private Sub Command1_Click() ’单机command1
s = 0 ‘定义变量
For i = 0 To 2 ’循环
Select Case i ’判断i
Case 0 ‘如果i=0
t = "儿童套餐" ’则t变成"儿童套餐"
p = 13 ‘p=13
Case 1
t = "标准套餐" ’同理
p = 18
Case 2
t = "商务套餐"
p = 25
End Select
If Check1(i).Value = 1 And Text1(i).Text <> "" Then ‘如果check(i)被选上且text1(i)不为空
List1.AddItem t & Val(Text1(i).Text) & "份" ’list1加入
s = s + Val(Text1(i)) * p ‘改变s的值
n = n + Val(Text1(i)) ‘改变s的值
End If
Next i
If s <> 0 Then ’如果s不为0
List1.AddItem "共:" & n & "份 " & "合计金额:" & s & "元" ‘则list1加入信息
End If
End Sub
Private Sub Command2_Click() ’单机command2
List1.Clear ’清空list1
End Sub
Private Sub Form_Load() ‘form加载
For i = 0 To 2 ‘循环
Text1(i).Enabled = False ’全部不许输入文字
Next i
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer) ‘text输入文字
If KeyAscii >= 33 Then
If KeyAscii <= vbKey9 And KeyAscii >= vbKey0 Then
Else
KeyAscii = 0
End If
End If ’如果不是数字就清除这个字
End Sub