469,917 Members | 1,852 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

ReDim Problem

I am trying to add one column to an existing array (code below). The ReDim
command gives the error:
-----------------------------------------------
Microsoft VBScript runtime error '800a0009'

Subscript out of range

/ListCGShowsGrouped.asp, line 58

------------------------------------------------

The Response.Write shows that the array has 9 rows and 3 cols (it displays 8
and 2) before the redim and I want a 9 x 4 after the redim.

What am I doing wrong here?

============ Code ===============

........
aryShows = myRS.GetRows
intRows = Ubound(aryShows,2)
intCols = Ubound(aryShows,1)
MyRS.Close

Response.Write("Rows: " & introws & " - Cols: " & intcols & "<br>")
Redim Preserve aryShows(intCols + 1, introws)
--
------------------------------------
Wayne Wengert
wa***@wengert.org
Jul 19 '05 #1
2 15557
You can only redimension the last dimension of an array.

<quote source="google search">
When using multi dimensional arrays, it is only possible to redim the last
dimension.

Say you array looks like this:

Dim myArr()
Redim myArr(5,5)

You will be able to do

Redim myArr(5,10)

But you won't be able to do

Redim myArr(10,5)

This behaviour is by design, so you can't get around it...
</quote>

Hope this helps (or not of course).

Chris.

"Wayne Wengert" <wa********@wengert.com> wrote in message
news:uR**************@tk2msftngp13.phx.gbl...
I am trying to add one column to an existing array (code below). The ReDim
command gives the error:
-----------------------------------------------
Microsoft VBScript runtime error '800a0009'

Subscript out of range

/ListCGShowsGrouped.asp, line 58

------------------------------------------------

The Response.Write shows that the array has 9 rows and 3 cols (it displays 8
and 2) before the redim and I want a 9 x 4 after the redim.

What am I doing wrong here?

============ Code ===============

........
aryShows = myRS.GetRows
intRows = Ubound(aryShows,2)
intCols = Ubound(aryShows,1)
MyRS.Close

Response.Write("Rows: " & introws & " - Cols: " & intcols & "<br>")
Redim Preserve aryShows(intCols + 1, introws)
--
------------------------------------
Wayne Wengert
wa***@wengert.org

Jul 19 '05 #2
Thanks Chris. Now that you remind me of that I do remember reading that
before - I forgot about that (senility!). Oh well, I'll do it the hard way.

Wayne

"Chris Barber" <ch***@blue-canoe.co.uk.NOSPAM> wrote in message
news:u2**************@TK2MSFTNGP10.phx.gbl...
You can only redimension the last dimension of an array.

<quote source="google search">
When using multi dimensional arrays, it is only possible to redim the last
dimension.

Say you array looks like this:

Dim myArr()
Redim myArr(5,5)

You will be able to do

Redim myArr(5,10)

But you won't be able to do

Redim myArr(10,5)

This behaviour is by design, so you can't get around it...
</quote>

Hope this helps (or not of course).

Chris.

"Wayne Wengert" <wa********@wengert.com> wrote in message
news:uR**************@tk2msftngp13.phx.gbl...
I am trying to add one column to an existing array (code below). The ReDim
command gives the error:
-----------------------------------------------
Microsoft VBScript runtime error '800a0009'

Subscript out of range

/ListCGShowsGrouped.asp, line 58

------------------------------------------------

The Response.Write shows that the array has 9 rows and 3 cols (it displays 8 and 2) before the redim and I want a 9 x 4 after the redim.

What am I doing wrong here?

============ Code ===============

.......
aryShows = myRS.GetRows
intRows = Ubound(aryShows,2)
intCols = Ubound(aryShows,1)
MyRS.Close

Response.Write("Rows: " & introws & " - Cols: " & intcols & "<br>")
Redim Preserve aryShows(intCols + 1, introws)
--
------------------------------------
Wayne Wengert
wa***@wengert.org

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Trevor Fairchild | last post: by
10 posts views Thread by Nathan Sokalski | last post: by
9 posts views Thread by John A Grandy | last post: by
2 posts views Thread by Fredrik Strandberg | last post: by
9 posts views Thread by Anil Gupte | last post: by
1 post views Thread by Freddy Coal | last post: by
2 posts views Thread by eBob.com | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.