- Dim v As Boolean '是否第一次按运算符
Dim x, y As Double '存放两次数
Private Sub Cmdcompute_Click(Index As Integer)
If v Then '第一次运算符
x = Val(Txtoutput.Text) '保存
v = False
Else
y = Val(Txtoutput.Text)
Select Case Index
Case 0
Txtoutput.Text = x + y - Case 1
Txtoutput.Text = x - y - Case 2
Txtoutput.Text = x * y - Case 3
If y <> 0 Then
Txtoutput.Text = x / y
Else
MsgBox ("Error") '如果除数为0,报错
Txtoutput.Text = x
v = False
End If
Case4
y = 0
v = False
End Select
x = Val(Txtoutput.Text)
End If
End Sub
Private Sub CmdNegative_Click()
Txtoutput.Text = Trim(Str(-Val(Txtoutput.Text)))
End Sub
Private Sub CmdNumber_Click(Index As Integer)
If Index = 10 Then
Txtoutput.Text = "0."
Else
Txtoutput.Text = CmdNumber(Index).Caption
End If
End Sub
Private Sub Command1_Click()
End Sub
Private Sub Command2_Click()
Txtoutput.Text = ""
v = False
End Sub
Private Sub end_Click()
Unload Me
End Sub
为什么 我在点 Cmdcompute时,出错,麻烦说详细一点,谢谢。