我到是有现成的函数
Public Function AryMidStr(sstr(),str)
On Error Resume Next
Dim tstr, mstr, tui
Dim i, num, j
num = 0
For i = 0 To Len(str)
tstr = Mid(str, i + 1, 1)
IF tstr = "," Then
num = num + 1
End If
Next
ReDim sstr(num)
j = 0
For i = 0 To Len(str)
tstr = Mid(str, i + 1, 1)
IF tstr <> "," Then
mstr = mstr & tstr
Else
IF j < num Then
sstr(j) = mstr
mstr = ""
j = j + 1
End If
End If
Next
AryMidStr = num
End Function
用法示例
<%
Dim AryT()
Dim num
Dim Str
Dim i
Str="a,b,c,d,e,f,"
num=AryMidStr(AryT,Str)
For i=0 to num
Response.Write "AryT("&CStr(i)&")="&AryT(i)&"<br>"
Next
%>
第一个参数是数组接收分离出来的字符串,第二个参数是未被分离的字符串。返回值返回数组的大小也就是数组的元素个数。