0

我对经典 ASP 和 Visual Basic 非常陌生。我无法进行简单的拆分。我有以下代码:

Dim sFileName, startDate, fsObject, filObject, oArray, oSplit
oArray = Split(Replace(Request.Form("txtOutput"),vbCrLf, "|"),"|")

For Idx = 0 To Ubound(oArray)
    oSplit = Split(oArray(Idx), ",")
    response.Write(oSplit & "</br>")

Next

txtOutput看起来像:

0342-John Doe,0,0,0,,
0134-Jane Doe,15,0,0,,
0343-John Smith,44.5,0,0,,

难道我做错了什么?

4

3 回答 3

1

猜猜你的代码应该是这样的:

Dim sFileName, startDate, fsObject, filObject, oArray, oSplit
oArray = Split(Replace(Request.Form("txtOutput"),vbCrLf, "|"),"|")

For Idx = 0 To Ubound(oArray)
    oSplit = Split(oArray(Idx), ",")

    For iloop=0 to ubound(oSplit)
        response.Write(oSplit(iloop) & "</br>")
    Next

Next

这样做的原因是因为您的代码中有两个拆分,您需要两个计数器来循环遍历所有项目

于 2012-07-05T21:27:27.880 回答
0

oSplit 是一个数组.. 你试图写一个数组,然后<br>

于 2012-07-05T17:33:34.187 回答
0

试试这个:

Dim sFileName, startDate, fsObject, filObject, oArray, oSplit
oArray = Split(Replace(Request.Form("txtOutput"),vbCrLf, "|"),"|")

If IsArray(oArray) Then
   For Idx = LBound(oArray) To Ubound(oArray)
       oSplit = Split(oArray(Idx), ",")
       If IsArray(oSplit) Then
          For Idx2 = LBound(oSplit) to uBound(oSplit)
             response.Write oSplit(Idx2) & "</br>"
          Next
       End If
   Next
End If

您收到此错误是因为您尝试response.write在数组而不是变量上使用。

于 2012-07-05T20:30:32.640 回答