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
[code:9800a89dc3]
Private Sub Command1_Click()
b = 0
s = Text1.text & " "
For i = 1 To Len(s)
m = Mid(s, i, 1)
Select Case Asc(m)
Case 48 To 57
Text2.text = Text2.text + m
If b > 0 Then b = b + 1
Case 46
b = 1
Case Else
If b > 0 Then
Text2.text = Text2.text & "/" & 10 ^ (b - 1)
End If
Text2.text = Text2.text + m
b = 0
End Select
Next
Text2.text = Trim(Text2.text)
End Sub
例如在模块中
[code:30ba443891]Public Type myType
a As String
b As String
End Type
Public Function bbb(a As myType)
'
End Function[/code:30ba443891]
在窗体中就可以这样用了
[code:30ba443891]Private Sub Command1_Click()
Dim c As myType
bbb c
End Sub[/code:30ba443891] 作者:
tkgg6034 时间: 2005-12-5 10:22