拆分投掷500错误

时间:2012-07-05 17:26:22

标签: asp-classic vb6

我是Classic 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,,

我做错了吗?

3 个答案:

答案 0 :(得分: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

这是因为你的代码中有两个分割,你需要两个计数器来遍历所有的itens

答案 1 :(得分:0)

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

答案 2 :(得分: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而不是变量。