我在网上看说要用一个什么控件,我用的是
For i = 1 To Len(Text1.Text)
If Mid(Text1.Text, i, 1) = "+" Then
s = Split(Text1.Text, "+")
For j = 0 To UBound(s)
Dim a(0 To 1) As Integer
a(j) = Val(s(j))
q = q + a(j)
Next j
ElseIf Mid(Text1.Text, i, 1) = "-" Then
s = Split(Text1.Text, "-")
For j = 0 To UBound(s)
Dim b(0 To 1) As Integer
b(j) = Val(s(j))
q = b(0) - b(1)
Next j
ElseIf Mid(Text1.Text, i, 1) = "*" Then
q = 1
s = Split(Text1.Text, "*")
For j = 0 To UBound(s)
Dim c(0 To 1) As Integer
c(j) = Val(s(j))
q = q * c(j)
Next j
ElseIf Mid(Text1.Text, i, 1) = "/" Then
s = Split(Text1.Text, "/")
For j = 0 To UBound(s)
Dim d(0 To 1) As Integer
d(j) = Val(s(j))
Next j
q = d(0) / d(1)
End If
Next i
Text1.Text = q
End Select
End Sub
有点多,还不能计算小数,请高手修改一下