Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 经典ASP Ubound返回9,下标超出范围_Arrays_Asp Classic_Session Variables - Fatal编程技术网

Arrays 经典ASP Ubound返回9,下标超出范围

Arrays 经典ASP Ubound返回9,下标超出范围,arrays,asp-classic,session-variables,Arrays,Asp Classic,Session Variables,抱歉,如果已涵盖此内容,我在搜索中找不到与此问题相关的任何内容 我正在尝试调试一个经典的ASP应用程序。我需要打印会话变量,其中一个是数组。我的代码如下所示,我不断地得到超出范围的下标,通常这意味着数组是空的(Ubound返回-1),但在本例中它返回为9。我尝试了I=1到4的和I=0到4的,得到了相同的结果 For Each Item In Session.Contents If IsArray(Session(item)) Then localArray =

抱歉,如果已涵盖此内容,我在搜索中找不到与此问题相关的任何内容

我正在尝试调试一个经典的ASP应用程序。我需要打印会话变量,其中一个是数组。我的代码如下所示,我不断地得到超出范围的下标,通常这意味着数组是空的(Ubound返回-1),但在本例中它返回为9。我尝试了I=1到4的
和I=0到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>&nbsp;&nbsp;" & 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 
也尝试过

localArray = Session(item)
Response.Write localArray(2) //since UBound returns 9 figured 2nd index should be safe

我仍然收到错误,看起来数组可能不是一维的。但是,我不熟悉此会话变量的结构或创建,是否有方法获取ASP中数组的结构?

假设
localArray
是一维数组,请将代码更改为

For i = LBound(localArray) To Ubound(localArray)
   Response.Write "<br>&nbsp;&nbsp;" & item 
   Response.Write "(" & i & ") = " & localArray(i) 
Next 
i=LBound(localArray)到Ubound(localArray)的

响应。写入“
”项(&P) Response.Write“(”&i&“””=“&localArray(i) 下一个
我可以在这里使用答案:获取数组的大小。我将代码更改为:

            localArray = Session(item) 

        colStart = LBound(localArray, 1)
        colEnd = UBound(localArray, 1)
        rowStart = LBound(localArray, 2)
        rowEnd = UBound(localArray, 2)

        For row = rowStart To RowEnd
            For col = colStart To colEnd
                Response.Write localArray(col,row) & "<br />"
            Next
        Next
localArray=会话(项)
colStart=LBound(localArray,1)
colEnd=UBound(localArray,1)
rowStart=LBound(localArray,2)
rowEnd=UBound(localArray,2)
对于行=行开始到行结束
对于col=colStart到colEnd
响应。写入本地数组(列,行)和“
” 下一个 下一个

所以今天我学习了
下标超出范围
在一个数组上,你知道它没有超出范围,这意味着它不是一个一维数组。

也尝试了这个方法,但没有成功。我不确定数组是如何构建的,因为我正在调试我没有编写的代码。。。我想我的问题可能是它不是一个一维数组。有没有办法知道数组的结构是什么?
            localArray = Session(item) 

        colStart = LBound(localArray, 1)
        colEnd = UBound(localArray, 1)
        rowStart = LBound(localArray, 2)
        rowEnd = UBound(localArray, 2)

        For row = rowStart To RowEnd
            For col = colStart To colEnd
                Response.Write localArray(col,row) & "<br />"
            Next
        Next