对不起,如果这已被覆盖,我找不到任何具体到我的搜索此问题。经典ASP Ubound返回9获取下标超出范围
我想调试一个经典的ASP应用程序。我需要打印会话变量,其中一个是数组。我的代码如下,我不断得到下标超出范围,通常这意味着该数组是空的(Ubound返回-1),但在这种情况下,它回来了9.我试过For i = 1 To 4
和For i = 0 To 4
具有相同的结果。
For Each Item In Session.Contents
If IsArray(Session(item)) Then
localArray = Session(item)
Response.Write "<h1>Ubound = " & Ubound(localArray) & "</h1> <br />" //getting Ubound = 9 here
For i = 1 To Ubound(localArray)
Response.Write "<br> " & item
Response.Write "(" & i & ") = " & localArray(i)
Next
Elseif IsObject(Session(item)) Then
Response.Write "<b>" & item & " is an object </b>"
Else
Response.Write item & " = " & Session(item)
End If
Response.Write "<br>"
Next
编辑
更改代码
For i = LBound(localArray) To UBound(localArray)
也曾尝试
localArray = Session(item)
Response.Write localArray(2) //since UBound returns 9 figured 2nd index should be safe
我仍然收到错误,好像阵列可能不是单一维度。但是,我不熟悉此会话变量的结构或创建,有没有办法获得ASP中的数组结构?
尝试这种方法以及没有运气。我不确定数组是如何构建的,因为我正在调试我没有写入的代码......我想我的问题可能是它不是单维数组。有什么方法可以说明数组的结构是什么? – jon3laze 2010-10-25 18:50:21