ReDim Problem

Discussion in 'ASP General' started by Wayne Wengert, Oct 30, 2003.

  1. 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
    Wayne Wengert, Oct 30, 2003
    #1
    1. Advertising

  2. Wayne  Wengert

    Chris Barber Guest

    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" <> wrote in message
    news:...
    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
    Chris Barber, Oct 30, 2003
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    > 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
    >
    >
    >
    >
    Wayne Wengert, Oct 30, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ante Perkovic
    Replies:
    0
    Views:
    595
    Ante Perkovic
    Jul 2, 2003
  2. Nathan Sokalski

    Problem with ReDim statement

    Nathan Sokalski, May 16, 2005, in forum: ASP .Net
    Replies:
    10
    Views:
    587
    Charles Law
    May 17, 2005
  3. Replies:
    4
    Views:
    855
    Chris Theis
    Dec 3, 2005
  4. redim an array

    , Nov 26, 2007, in forum: C Programming
    Replies:
    7
    Views:
    350
  5. keyser soze

    REDIM Preserve problem

    keyser soze, May 6, 2008, in forum: ASP General
    Replies:
    4
    Views:
    266
    keyser soze
    May 7, 2008
Loading...

Share This Page