Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3312694
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:01:32+00:00 2026-05-17T22:01:32+00:00

Sorry if this has been covered, I couldn’t find anything specifically to this issue

  • 0

Sorry if this has been covered, I couldn’t find anything specifically to this issue in my searches.

I am trying to debug a classic ASP application. I need to print the session variables, one of which is an array. My code is below, I keep getting Subscript out of range, usually this means that the array is empty (Ubound returns -1) but in this case it’s coming back as 9. I’ve tried For i = 1 To 4 and For i = 0 To 4 with the same results.

 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 

EDIT

Changed code to

For i = LBound(localArray) To UBound(localArray)

Have also tried

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

I still receive the error, it seems like the array may not be single dimension. However I am not familiar with the structure or creation of this session variable, is there a way to get the structure of an array in ASP?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:01:33+00:00Added an answer on May 17, 2026 at 10:01 pm

    I was able to use the answer here: How many dimensions in my array or get the last one to obtain the size of the array. I changed my code to:

                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
    

    So today I learned Subscript out of range on an array you know is not out of range, means that it is not a single dimensional array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if this has been asked before, but I couldn't find a solution to
Sorry if this has been asked elsewhere. I have looked but can't find any
Sorry if this has been answered before, but I am trying to make an
Sorry if this has been asked already, I've did a google search and couldn't
Sorry I couldn't find the best heading for this question. Following is my requirement.
Sorry if this has been asked before, but I am wondering what the use
Sorry if this has been asked, my search brought up many off topic posts.
Sorry if this has been asked before, but I'm wondering what the best memory
Sorry if this has been asked. Just like I can select in C# project
Sorry if this has been answered somewhere; I'm not quite sure how to phrase

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.