dage23wo 发表于 2015-4-8 13:06:36

求大神指导

Private Sub Command1_Click()

Dim a, b, c As Integer
Dim a1 As String
a1 = Text1.Text
a = 0
b = 0
c = 0
Call shiqu(a1, a, b, c)

Text2.Text = a

End Sub
Function shiqu(ByRef TT As String, ByRef n As Integer, ByRef m As Integer, ByRef p As Integer)
Dim AAA, BBB As String
Dim I, JJ, CC As Integer
Dim a, b, c As Integer

AAA = TT

CC = Len(AAA)
BBB = ""

If CC >= 11 Then
I = 4
For JJ = 1 To I
If Asc(Mid(AAA, JJ, 1)) >= 48 And Asc(Mid(AAA, JJ, 1)) <= 57 Then
BBB = BBB & Mid(AAA, JJ, 1)
Else
I = I + Val(BBB)
BBB = ""
End If
Next
a = 0
a = Val(BBB)
n = a

For JJ = 1 To 9
If Asc(Mid(AAA, JJ, 1)) >= 48 And Asc(Mid(AAA, JJ, 1)) <= 57 Then
BBB = BBB & Mid(AAA, JJ, 1)
Else
I = I + Val(BBB)
BBB = ""
End If
Next
b = 0
b = Val(BBB)
m = b

For JJ = 1 To CC
If Asc(Mid(AAA, JJ, 1)) >= 48 And Asc(Mid(AAA, JJ, 1)) <= 57 Then
BBB = BBB & Mid(AAA, JJ, 1)
Else
I = I + Val(BBB)
BBB = ""
End If
Next
d = 0
d = Val(BBB)
p = d

Else: I = 3
For JJ = 1 To I
If Asc(Mid(AAA, JJ, 1)) >= 48 And Asc(Mid(AAA, JJ, 1)) <= 57 Then
BBB = BBB & Mid(AAA, JJ, 1)
Else
I = I + Val(BBB)
BBB = ""
End If
Next
a = 0
a = Val(BBB)
n = a

For JJ = 1 To 7
If Asc(Mid(AAA, JJ, 1)) >= 48 And Asc(Mid(AAA, JJ, 1)) <= 57 Then
BBB = BBB & Mid(AAA, JJ, 1)
Else
I = I + Val(BBB)
BBB = ""
End If
Next
b = 0
b = Val(BBB)
m = b

For JJ = 1 To CC
If Asc(Mid(AAA, JJ, 1)) >= 48 And Asc(Mid(AAA, JJ, 1)) <= 57 Then
BBB = BBB & Mid(AAA, JJ, 1)
Else
I = I + Val(BBB)
BBB = ""
End If
Next
d = 0
d = Val(BBB)
p = d
End If


End Function


zzyong00 发表于 2015-4-8 13:58:51

你的问题是?

dage23wo 发表于 2015-4-8 14:06:14

zzyong00 发表于 2015-4-8 13:58 static/image/common/back.gif
你的问题是?

运行出来总显示参数类型不符。我是想利用子程序调用筛选出text1中的400X400X12 的数字400,400,12

zzyong00 发表于 2015-4-8 16:38:56

唉,建议先看看基础,数据类型、怎么定义变量等

wwswwswws 发表于 2015-4-13 13:35:06

同楼上,建议先看看基础部分

dim ss as string
dim s() as string
dima as long,b as long,c as long

ss="400X400X12"
s=split(ss,"X")
a=clng(s(0))
b=clng(s(1))
c=clng(s(2))
debug.print "a=" & a & vbcrlf & "b=" & b & vbcrlf "c=" & c
页: [1]
查看完整版本: 求大神指导