日期:2014-05-17  浏览次数:20961 次

一个变量如何使用split函数分割到二维数组中呢?
BL   =   "0023,元素2,1.34-0003,元素5,1.05-0014,元素1,0.02 "
上面是一个变量,怎么通过循环把他分割到二维数组中呢?得出效果如下:
arr(0,0)   =   "0023 "
arr(0,1)   =   "元素2 "
arr(0,2)   =   "1.34 "

arr(1,0)   =   "0003 "
arr(1,1)   =   "元素5 "
arr(1,2)   =   "1.05 "

arr(2,0)   =   "0014 "
arr(2,1)   =   "元素1 "
arr(2,2)   =   "0.02 "

------解决方案--------------------
BL = "0023,元素2,1.34-0003,元素5,1.05-0014,元素1,0.02 "
b = split(BL, "- ")
c = split(b(0), ", ")
Dim a()
ReDim a(UBound(b),UBound(c))

For i=0 To UBound(b)
d = split(b(i), ", ")
For j=0 To UBound(c)
a(i,j) = d(j)
Next
Next
For i=0 To UBound(a,2)
For j=0 To UBound(c)
Response.Write a(i,j) & " <br> "
Next
Next
------解决方案--------------------
arrBL = split(BL, "- ")
for i =0 to ubound(arrBL)
for j = 0 to ubound(split(arrBL(i), ", "))
arr(i,j)=split(arrBL(i), ", ")(j)
next
next
------解决方案--------------------
dim i,j,ayy
ayy = split(BL, "- ")
i = ubound(ayy)
for j = 0 to i
arr(j)=split(arr(j), ", ")
next