在编程过程中遇到算术程序问题,忘指引。
RT,在编程过程中遇到一个算术程序问题,忘指引。我制作的是一个简单的包括(+ - * /)的算术程序,但是算加法总是不正常,比如说50+50应该是100,而我制作的程序50+50是5050,其他的正常。以下是代码,请问大神怎么改?
Option Explicit
Dim opt As String
Private Sub Command1_Click()
opt = "+"
End Sub
Private Sub Command2_Click()
opt = "-"
End Sub
Private Sub Command3_Click()
opt = "*"
End Sub
Private Sub Command4_Click()
opt = "/"
End Sub
Private Sub Command5_Click()
Dim a, b, result As Double
a = Text1.Text
b = Text2.Text
Select Case opt
Case "+"
result = a + b
Case "-"
result = a - b
Case "*"
result = a * b
Case "/"
If b <> 0 Then
result = a / b
Else
MsgBox "除数不能为0,请修改!"
End If
End Select
Text3.Text = result
End Sub