vb split 用法

Fori=1ToAllNum1(LineNum1)NumberNum1(LineNum1,i)=Split(Split(s,",")(i),",")(0)Nexti是什么... For i = 1 To AllNum1(LineNum1)
NumberNum1(LineNum1, i) = Split(Split(s, ",")(i), ",")(0)
Next i
是什么意思啊,尤其是Split(Split(s, ",")(i), ",")(0)怎么理解?特别是Split(Split(s, ",")(i), ",")后面的那个(0)什么意思啊?split函数后面加个(0)怎么理解,谢谢各位大侠!
我把代码发全一点,各位大侠帮忙看下,代码没问题,测试过了
Open PathIn1 For Input As #1
Do Until EOF(1) = True
Line Input #1, s
s = "," & s & ","
LineNum1 = LineNum1 + 1
Nnum = 0
For i = 1 To Len(s)
If Mid(s, i, 1) = "," Then Nnum = Nnum + 1
Next i
AllNum1(LineNum1) = Nnum - 1
For i = 1 To AllNum1(LineNum1)
NumberNum1(LineNum1, i) = Split(Split(s, ",")(i), ",")(0)
Next i
Loop
Close #1
展开
 我来答
mafan8
推荐于2018-04-11 · TA获得超过1.7万个赞
知道小有建树答主
回答量:927
采纳率:0%
帮助的人:777万
展开全部
Split(Split(s, ",")(i), ",")(0)输出是s字符串通过","分割后的第i个数组内的字符再次使用","分割后的第0个数组内的字符
比如s=",1,2,3,4,5,"
此时AllNum1(LineNum1)=5,LineNum1=1
For i = 1 To AllNum1(LineNum1)
NumberNum1(LineNum1, i) = Split(Split(s, ",")(i), ",")(0)
Next i
split过程如下
Split(s, ",")(0)=""
Split(s, ",")(1)="1"
Split(s, ",")(2)="2"
Split(s, ",")(3)="3"
Split(s, ",")(4)="4"
Split(s, ",")(5)="5"
Split(s, ",")(6)=""
外面再有一级split
是将上面分割的字符串再次通过 ","分割并取分割后的第一个字符
mR_FRkWN
2010-07-14 · 超过27用户采纳过TA的回答
知道答主
回答量:51
采纳率:0%
帮助的人:85.6万
展开全部
觉得这代码有一点点问题
Split()返回一个按所给分割符切开的数组,如a=Split("a,b,c",",")得到
a(0)="a" a(1)="b" a(2)="c"

代码的字面意思是:循环1~AllNum1(LineNum1)过程中,给NumberNum1(LineNum1, i)赋值,值为a,其中:
用“,”分割s后所得的第i项,再用“,”分割此项取头项,将头项赋给a

问题是:第一个split返回的字符串数组不可能再含有","

试一下把Split(Split(s, ",")(i), ",")(0)改成Split(s, ",")(i)看结果相同不,怀疑外面的split不起作用。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友9260c4507
2010-07-14 · TA获得超过2328个赞
知道大有可为答主
回答量:3736
采纳率:0%
帮助的人:2411万
展开全部
Split函数最后返回的结果是个数组
所以(0)就表示该数组的第一个元素值
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式