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 8659999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:08:47+00:00 2026-06-12T16:08:47+00:00

OK I’m a complete newbie to ASP. I have a client with different content

  • 0

OK I’m a complete newbie to ASP.

I have a client with different content loading depending on what is passed in an array.

select case lcase(arURL(4))

Sometimes though, arURL(4) might be empty, in them cases I’m getting the following error:

Error running function functionName(), the error was:

Subscript out of range

Does anybody know a way to fix this?

Thanks

OK further code as requested. It is horrible code and I don’t mean to cause anybody a headache, so please excuse it. Thanks again ……..

function GetContent()
    dim strURL, arURL, strRetval
    select case lcase(request.ServerVariables("URL"))
        case "/content.asp"
            strURL = ""
            arURL = split(request.querystring("url"), "/")
            if request("page") = "" then
                select case lcase(arURL(2))
                    case "searches"
                        select case lcase(arURL(1))
                            case "looking"
                                select case lcase(arURL(3))
                                    case "ohai"
                                        strRetval = "Lorem"
                                    case "blahblah"
                                        strRetval = "Lorem Ipsum"                        
                                    case "edinburgh"
                                        select case lcase(arURL(4))
                                            case "ohai"
                                                strRetval = "Ipsum"
                                            case "ohno"
                                                strRetval = "Lorem"
                                        end select
                                    case "bristol"
                                        select case lcase(arURL(4))
                                            case "some_blahblah"
                                                strRetval = "LOREM"
                                            case "overthere"
                                                strRetval = "LOREM"
                                            case "blahblah"
                                                strRetval = "LOREM"
                                        end select
                                    case "cambridge"
                                        select case lcase(arURL(4))
                                            case "some_rubbish"
                                                strRetval = "Lorem"
                                        end select
                                    case else
                                        strRetval = " "
                                end select
                            case else
                                strRetval = " "
                        end select
                    case else
                        strRetval = " "
                end select 
            end if
    end select 
    strRetval = strRetval & "<style>h2{border: 0px);</style>"
    GetContent = strRetval
end function
  • 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-06-12T16:08:48+00:00Added an answer on June 12, 2026 at 4:08 pm

    You are using value passed over the querystring and split it by “/” character – when the value does not contain “enough” slashes, you will get error and the code will crash.

    For example, if the querystring parameter url will be only “/something” then even arURL(2) will fail since the array has only two items. (First one is empty string, second is “something”)

    To avoid all this mess, best way I can advice is writing custom function that will take array and index as its arguments and return either the item in the given index if exists otherwise empty string:

    Function GetItemSafe(myArray, desiredIndex, defValue)
        If (desiredIndex < LBound(myArray)) Or (desiredIndex > UBound(myArray)) Then
            If IsObject(defValue) Then
                Set GetItemSafe = defValue
            Else  
                GetItemSafe = defValue
            End If
        Else  
            If IsObject(myArray(desiredIndex)) Then
                Set GetItemSafe = myArray(desiredIndex)
            Else  
                GetItemSafe = myArray(desiredIndex)
            End If
        End If
    End Function
    

    (ended up with more generic version, letting the calling code decide what is the default value in case index is out of array range)

    Having this, change your code to use the function instead of accessing the array directly.

    This line for example:

    select case lcase(arURL(2))
    

    Should become this instead:

    select case lcase(GetItemSafe(arURL, 2, ""))
    

    Change the rest of those lines accordingly and you’ll no longer get errors when the given value won’t be valid.

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

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have an array which has BIG numbers and small numbers in it. I
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into

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.