VBScript不会超过if语句
问题描述:
我有一个简单的VBScript
,它从数据库获取数据并遍历它们并生成一个表。在此迭代期间,我想捕获一些数据(特定列的值)并将它们保存在变量*以后使用。但是每当我的代码达到if
声明它不会循环。VBScript不会超过if语句
Dim lats
Dim longs
Set lats = CreateObject("System.Collections.ArrayList")
Set longs = CreateObject("System.Collections.ArrayList")
%>
<table>
<tr><th>Office</th><th>Address</th><th>Comune</th><th>Province</th><th>Lat</th><th>Long</th><th>2G</th><th>3G</th><th>4G</th></tr>
<%do until rs.EOF
response.write("<tr>")
for each x in rs.Fields
response.write("<td>" & response.write(x.value) &"</td>")
'IF the below statement equals true, the loop doesn't perform anymore
If x.name = "SITE_LAT_N" Then
lats.Add x.value
ElseIf x.name = "SITE_LON_E" Then
longs(indx) = x.value
End If
next
rs.MoveNext
response.write("</tr>")
loop
rs.close
conn.close
%>
</table>
答
longs(indx) = x.value
看起来腥。证据:
>> set al = CreateObject("System.Collections.ArrayList")
>> al.Add "works"
>> WScript.echo al(0)
>> al(1) = "doesn't work"
>>
works
Error Number: -2146233086
Error Description: Der Index lag außerhalb des Bereichs. Er muss nicht negativ und kleiner als die Auflistung sein.
Parametername: index
另外:indx
从哪里来?你不能使用
longs.add x.value
+0
公平评估。 – Lankymart
我猜你在代码中有'On Error Resume Next'。删除它并查看显示的错误。另外,不要在Response.Write里面调用Response.Write。 – Tomalak
不,我没有,在我的代码的下一个任何地方的错误恢复。另外我修复了Response.Write,但是循环不能继续。 –