''''''''''本程序是一个计算器程序
Dim v As Boolean
Dim s As Integer
Dim x As Double
Dim y As Double
'''''定义全局变量
Private Sub Command1_Click(Index As Integer)If Form1.Tag = "s" Then
If Index = 10 Then
Text1.Text = "0."
Else
Text1.Text = Command1(Index).Caption
End If
Form1.Tag = ""
Else
Text1.Text = Text1.Text & Command1(Index).Caption
End IfEnd Sub
''''''''上面是把输入的内容赋值给文本输入框
''''''''command1()控件数组的11个按钮分别是0-9和。
Private Sub Command2_Click(Index As Integer)Form1.Tag = "s"If v Then
x = Val(Text1.Text)
v = Not v
Else
y = Val(Text1.Text)
Select Case s
Case 0
Text1.Text = x + y
Case 1
Text1.Text = x - y
Case 2
Text1.Text = x * y
Case 3
If y <> 0 Then
Text1.Text = x / y
Else
MsgBox ("不能以0为除数")
Text1.Text = x
v = False
End If
Case 4
y = 0
v = False
End Select
x = Val(Text1.Text)
End If
s = Index
End Sub
'''''''''''command2()控件数组的5个按钮分别是+、-、*、/和=
''''''''''''''''''''''''
我不明白的地方是布尔型V和.tag的含义和他的用法
Dim v As Boolean
Dim s As Integer
Dim x As Double
Dim y As Double
'''''定义全局变量
Private Sub Command1_Click(Index As Integer)If Form1.Tag = "s" Then
If Index = 10 Then
Text1.Text = "0."
Else
Text1.Text = Command1(Index).Caption
End If
Form1.Tag = ""
Else
Text1.Text = Text1.Text & Command1(Index).Caption
End IfEnd Sub
''''''''上面是把输入的内容赋值给文本输入框
''''''''command1()控件数组的11个按钮分别是0-9和。
Private Sub Command2_Click(Index As Integer)Form1.Tag = "s"If v Then
x = Val(Text1.Text)
v = Not v
Else
y = Val(Text1.Text)
Select Case s
Case 0
Text1.Text = x + y
Case 1
Text1.Text = x - y
Case 2
Text1.Text = x * y
Case 3
If y <> 0 Then
Text1.Text = x / y
Else
MsgBox ("不能以0为除数")
Text1.Text = x
v = False
End If
Case 4
y = 0
v = False
End Select
x = Val(Text1.Text)
End If
s = Index
End Sub
'''''''''''command2()控件数组的5个按钮分别是+、-、*、/和=
''''''''''''''''''''''''
我不明白的地方是布尔型V和.tag的含义和他的用法
x = Val(Text1.Text)
v = Not v '不如写false更好明白一些!