level 1
Dim ops1﹠﹐ops2﹠, 记录两个操作数
Dim op As Byte, 记录输入的运算符
Dim res As Boolean, 表示是否已计算出结果
Private Sub Form_Load()
res = False
End Sub
Private Sub cmdClear_Click()
Dataout.Text = ""
End Sub
Private Sub cmdNumber_Click(Index As Integer)
If Not res Then
Dataout.Text = Dataout.Text & Index
Else
Dataout.Text = Index
res = False
End If
End Sub
Private Sub cmdOperator_Click(Index As Integer)
ops1 = Dataout.Text
op = Index '记录下对应的运算符
Dataout.Text = ""
End Sub
Private Sub cmdresult_Click()
osp2 = Dataout.Text
Select Case op
Case 0
Dataout.Text = ops1 + ops2
Case 1
Dataout.Text = ops1 - ops2
Case 2
Dataout.Text = ops1 * ops2
Case 3
If osp2 <> 0 Then
Dataout.Text = ops1 / ops2
Else
MsgBox ("不能以0为除数")
Dataout.Text = ""
End If
End Select
res = True '已算出结果
End Sub
2021年06月25日 10点06分




