结果出乎意外啊
Private Type fs
fz As Variant
fm As Integer
End Type
Dim sz() As fs
Public Function gesuo(text As String) As Integer
Dim i, n As Integer
Dim fh As String
n = 1
For i = 1 To Len(text)
fh = Mid(text, i, 1)
Select Case fh
Case Is = "+"
n = n + 2
Case Is = "-"
n = n + 2
Case Is = "*"
n = n + 2
Case Is = "/"
n = n + 2
Case Is = "^"
n = n + 2
Case Is = "("
n = n + 2
Case Is = ")"
n = n + 2
End Select
Next i
gesuo = n + 2
End Function
Private Sub Command1_Click()
Static temp As String
Dim m As Variant
Static i As Integer
Dim b, x As Integer
b = 1
temp = ""
y = gesuo(Text1.text)
For x = 1 To y - 1
n = Len(Text1.text)
For i = 1 To n
m = Mid(Text1.text, i, 1)
If IsNumeric(m) Then
temp = temp + m
ElseIf m = "." Then
b = b * 10
Else
ReDim Preserve sz(x) As fs
sz(x).fz = Val(temp)
sz(x).fm = b
temp = ""
b = 10
Text2.text = Text2.text & Str(sz(x).fz) + "/" & Str(sz(x).fm)
x = x + 1
ReDim Preserve sz(x) As fs
sz(x).fz = m
Text2.text = Text2.text & sz(x).fz
End If
Next i
Next x
End Sub
这次能看懂了吧
当text1.text=2.5+3.6时
结果等于25/10+3625/1000+
为什么啊
本来应该等25/10+36/10啊
最后那个+是怎么出来的
temp我以经清空了,为什么36后面还有一个25啊
b的值在运行一次后,我也恢复在b=1了,为什么还会有1000啊
哪错了啊,这一个地方我以经用了三天了,还是过不去,我是不是真的好笨
唉,