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 展开
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 展开
3个回答
展开全部
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
是将上面分割的字符串再次通过 ","分割并取分割后的第一个字符
比如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
是将上面分割的字符串再次通过 ","分割并取分割后的第一个字符
展开全部
觉得这代码有一点点问题
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不起作用。
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不起作用。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Split函数最后返回的结果是个数组
所以(0)就表示该数组的第一个元素值
所以(0)就表示该数组的第一个元素值
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询