建text1 为输入的第1个数,一个combobox存放运算符号,text2 为输入的第二个数 text3 为得数 按钮1为确定 按钮2为退出
=========
Private Sub Command1_Click()
If IsNumeric(Text1.Text) And Text1.Text <> "" And IsNumeric(Text3.Text) And Text3.Text <> "" Then
Select Case Combo1.ListIndex
Case 0
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
Case 1
Text3.Text = Val(Text1.Text) - Val(Text2.Text)
Case 2
Text3.Text = Val(Text1.Text) * Val(Text2.Text)
Case 3
If Val(Text1.Text) <> 0 Then
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
Else
MsgBox "分母不能为0", , "错误"
End If
Case 4
Text3.Text = Val(Text1.Text) \ Val(Text2.Text)
Case 5
Text3.Text = Val(Text1.Text) Mod Val(Text2.Text)
End Select
Else
MsgBox "请输入操作数", , "错误"
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Combo1.AddItem "+"
Combo1.AddItem "-"
Combo1.AddItem "*"
Combo1.AddItem "/"
Combo1.AddItem "\"
Combo1.AddItem "mod"
End Sub
温馨提示:内容为网友见解,仅供参考