字符串转二维数组的问题

billpu 2008-04-18 11:00:31
有哪位知道字符串转二维数组的方法吗
比如字符串"1,2,3|4,5,6|7,8,9"
split可以把字符串转一列数组
string=split("1,2,3|4,5,6|7,8,9","|")
有没有办法或者有函数自动可以转成2维的数组

1 2 3
4 5 6
7 8 9
...全文
126 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dogfish 2008-04-19
  • 打赏
  • 举报
回复

<%
a="1,2,3|4,5,6|7,8,9"
b=split(a,"|")
for i=0 to ubound(b)
b(i)=split(b(i),",")
Next


'Display the array
For i =0 To UBound(b)
For j=o To UBound(b(i))
response.write b(i)(j)
Next
Next
%>
smartcatiboy 2008-04-18
  • 打赏
  • 举报
回复
test:Sub test()
Dim i,j,aastr,str
aastr=str2ary("1,2,3|4,5,6|7,8,9")

For i=0 To UBound(aastr,1)
For j=0 To UBound(aastr,2)
str=str & aastr(i,j) & " "
Next
str=str & vbcrlf
Next
MsgBox str
End Sub


function str2ary(strIn)
Dim str,astr,aastr,astrtmp,iubound1,iubound2,i,j

astr=split(strIn,"|")

iubound1=ubound(astr)
iubound2=ubound(split(astr(0),","))

redim aastr(iubound1,iubound2)
for i=0 to iubound1
astrtmp=split(astr(i),",")
For j=0 To iubound2
aastr(i,j)=astrtmp(j)
next
next
str2ary=aastr
end function
'--------------

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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