明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 777|回复: 4

求大神指导

[复制链接]
发表于 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


发表于 2015-4-8 13:58:51 | 显示全部楼层
你的问题是?
 楼主| 发表于 2015-4-8 14:06:14 | 显示全部楼层
zzyong00 发表于 2015-4-8 13:58
你的问题是?

运行出来总显示参数类型不符。我是想利用子程序调用筛选出text1中的400X400X12 的数字400,400,12
发表于 2015-4-8 16:38:56 | 显示全部楼层
唉,建议先看看基础,数据类型、怎么定义变量等
发表于 2015-4-13 13:35:06 | 显示全部楼层
同楼上,建议先看看基础部分

dim ss as string
dim s() as string
dim  a 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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 11:59 , Processed in 0.174126 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表