vb split 用法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函数后面

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/09 00:40:41

vb split 用法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函数后面
vb split 用法
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

vb split 用法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函数后面
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
是将上面分割的字符串再次通过 ","分割并取分割后的第一个字符