急急!!!一个截取字符串的问题!!!!!

jiawei0806 2004-09-17 01:27:24
现在又一个字符串eg: str="23,234,343,23422323,23323423"
这个字符串第一个逗号前是两位,最后一个逗号后是8位,中间的位数就不定了
那末我该怎么才能把这个字符串的数值取出呢??????
是以逗号为标志来截取的
...全文
204 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
wts173 2004-09-20
  • 打赏
  • 举报
回复
以上都对
wwqna 2004-09-19
  • 打赏
  • 举报
回复
学习
flc 2004-09-19
  • 打赏
  • 举报
回复
非常喜欢 northwolves(狼行天下) 的方法,
因为狼兄的方法使人开阔视野……
熊孩子开学喽 2004-09-17
  • 打赏
  • 举报
回复
使用Split函数:
Dim InStr as string
dim OutArr '我试下来,只有定义为自动变量,才能获得Split分割得到的数组。
InStr= "23,234,343,23422323,23323423"
OutArr=Split(InStr,",")
'这样就可以了。InStr中的字符串已经被分割到OutArr中了。此时OutArr已经被自动转化成一个字符型数组,你可以直接使用:OutArr(0),OutArr(1)等普通数组的操作来访问其内容。
northwolves 2004-09-17
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Const Str = "23,234,343,23422323,23323423"
Dim pos As Integer, temp As String
temp = Str
Do
pos = InStr(temp, ",")
Debug.Print Left(temp, pos - 1)
temp = Mid(temp, pos + 1)
Loop Until InStr(temp, ",") = 0
Debug.Print temp
End Sub
tztz520 2004-09-17
  • 打赏
  • 举报
回复
dim strTemp as string
dim arrTemp() as string
dim i as long

strTemp="23,234,343,23422323,23323423"
arrTemp= Split(strTemp, ",")

for i = 0 to Ubound(arrTemp)
debug.print trim(arrTemp(i))'得到的数
next i
apple1980 2004-09-17
  • 打赏
  • 举报
回复
Split函数

返回一个下标从零开始的一维数组,它包含指定数目的子字符串。
xrhone 2004-09-17
  • 打赏
  • 举报
回复
楼上的都说了。用split()函数就行了
bladeinside 2004-09-17
  • 打赏
  • 举报
回复
split()函数
yujiang930 2004-09-17
  • 打赏
  • 举报
回复
dim ss() as string
dim i as integer
dim Result as string
ubound(split(str)) '返回数组的个数
ss=split(str)
for i=0 to ubound(split(str))
Result=result+ss(i)
next i
msgbox result 'result则是你要的结果
zcm123 2004-09-17
  • 打赏
  • 举报
回复
dim arr() as string

arr = split(text1, ",")

for i = 0 to Ubound(arr)
debgu.print trim(arr(i))
next i
zichen66 2004-09-17
  • 打赏
  • 举报
回复
用Split函數
dim MyVal() as long
dim i as integer
Myval=split(str,",")
for i=0 to ubound(myval)
msgbox myval(i)
next

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧