HELP! Subscript Out Of Range error referencing array 
Author Message
 HELP! Subscript Out Of Range error referencing array

Howdy folks,

I've been working on an ASP application for the last week or so which I've
done some funky things with, including parsing the query string returned
from posting a form into an array which I then want to use elsewhere.  This
is all Server-side VBScript btw...

Now... the problem I'm having is that if I use standard VB conventions for
passing this array into functions and subprocedures I'm either getting an
"array subscript out of range" or "object required", depending on what I'm
trying to do.

I've tried to make the Array public in the code that runs when the ASP page
loads to see if this makes a difference but it doesn't seem to.

The basic structure is:
------------------------------------------------------------
<%
    public Args (20,2)
    'other dim statements
    'sub and function declarations
    Sub listArgs()
        dim i
        if UBound(Args) <> 0 then
            for i = LBound(Args) to UBound(Args)
                response.write(Args(i,0) & "=")
                response.write(Args(i,1) & "<br> & vbCrLf)
            next
        end if
    end sub

    'Feed the pairs from the query string into the Args() array
    ListArgs
%>
------------------------------------------------------------
All pretty simple but the Ubound function is returning Object Required
messages and remming out the "if" and "for" constructs gives me Subscript
Out Of Range errors [even for Args(0,0)].  I've tried passing Args() as a
parameter as well but with identical results.

I'm now starting to wonder if VBScript actually supports the passing of
arrays to functions at all.  If someone could shoot me an email letting me
know what I've done wrong I'd be very grateful.

Thanks

Jeremy
http://www.*-*-*.com/



Fri, 16 Sep 2005 12:19:19 GMT  
 HELP! Subscript Out Of Range error referencing array
No matter - I've got it sussed now.

Had the  passing format for Args() wrong and because it's a two-dimensional
array I needed to specify UBound(Args, 1) to get the length of the first
array.

Thanks anyway for people who might have taken the time to look at this.

Jeremy

Quote:
> Howdy folks,

> I've been working on an ASP application for the last week or so which I've
> done some funky things with, including parsing the query string returned
> from posting a form into an array which I then want to use elsewhere.
This
> is all Server-side vbscript btw...

> Now... the problem I'm having is that if I use standard VB conventions for
> passing this array into functions and subprocedures I'm either getting an
> "array subscript out of range" or "object required", depending on what I'm
> trying to do.

> I've tried to make the Array public in the code that runs when the ASP
page
> loads to see if this makes a difference but it doesn't seem to.

> The basic structure is:
> ------------------------------------------------------------
> <%
>     public Args (20,2)
>     'other dim statements
>     'sub and function declarations
>     Sub listArgs()
>         dim i
>         if UBound(Args) <> 0 then
>             for i = LBound(Args) to UBound(Args)
>                 response.write(Args(i,0) & "=")
>                 response.write(Args(i,1) & "<br> & vbCrLf)
>             next
>         end if
>     end sub

>     'Feed the pairs from the query string into the Args() array
>     ListArgs
> %>
> ------------------------------------------------------------
> All pretty simple but the Ubound function is returning Object Required
> messages and remming out the "if" and "for" constructs gives me Subscript
> Out Of Range errors [even for Args(0,0)].  I've tried passing Args() as a
> parameter as well but with identical results.

> I'm now starting to wonder if VBScript actually supports the passing of
> arrays to functions at all.  If someone could shoot me an email letting me
> know what I've done wrong I'd be very grateful.

> Thanks

> Jeremy
> http://escapenow.curvedspaces.com



Fri, 16 Sep 2005 13:11:26 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Defining an array and getting Subscript Out of Range Error

2. Subscript out of range Error when using Arrays

3. help with subscript out of range error

4. Help! Error # 9 - Subscript out of range

5. array subscript out of range

6. Passing Arrays to Functions - Subscript Out of Range Problem

7. Array Subscript out of range:

8. subscript out of range? (floating array problem)

9. Arrays Problem SUBSCRIPT OUT OF RANGE

10. Subscript Out Of Range Error

11. Subscript out of range error

12. Subscript out of range error

 

 
Powered by phpBB® Forum Software