2个回答
展开全部
我现在给出的程序只能实现两个数相加、相减、相乘、相除,希望有所帮助
Private Sub Command1_Click()
a = InputBox("")
Print "表达式:"; a
For i = 1 To Len(a)
x = Mid(a, i, 1)
If Not IsNumeric(x) Then
m = Mid(a, 1, i - 1)
n = Mid(a, i + 1, Len(a))
pp = Mid(a, i, 1)
If pp = "+" Then
Print "结果:"; Val(m) + Val(n)
End If
If pp = "-" Then
Print "结果:"; m - n
End If
If pp = "*" Then
Print "结果:"; m * n
End If
If pp = "/" Then
Print "结果:"; m / n
End If
End If
Next
End Sub
Private Sub Command1_Click()
a = InputBox("")
Print "表达式:"; a
For i = 1 To Len(a)
x = Mid(a, i, 1)
If Not IsNumeric(x) Then
m = Mid(a, 1, i - 1)
n = Mid(a, i + 1, Len(a))
pp = Mid(a, i, 1)
If pp = "+" Then
Print "结果:"; Val(m) + Val(n)
End If
If pp = "-" Then
Print "结果:"; m - n
End If
If pp = "*" Then
Print "结果:"; m * n
End If
If pp = "/" Then
Print "结果:"; m / n
End If
End If
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询