Redimensioning a 2D array

Results 1 to 6 of 6

Thread: Redimensioning a 2D array

  1. #1
    Join Date
    Dec 1969
    Posts
    717

    Default Redimensioning a 2D array

    I have a 2D array that needs to be redimesioned. Here is what I am trying to use...<BR><BR>ReDim Preserve ExpArray(cInt(ArrayPos)-1,6)<BR><BR>I try this, but I keep getting "Subscript out of range." Any ideas what to do?

  2. #2
    Join Date
    Dec 1969
    Posts
    203

    Default RE: Redimensioning a 2D array

    try this<BR><BR>dim temp<BR>temp = cInt(ArrayPos)-1<BR>ReDim Preserve ExpArray(temp,6) <BR>

  3. #3
    Join Date
    Dec 1969
    Posts
    717

    Default Same Result.

    NT

  4. #4
    Join Date
    Dec 1969
    Posts
    3,921

    Default Must be like this...

    ... to support Redim Preserve on a multi-dimensional array.<BR>The variable number of elements must exist on the RIGHT side of the array. Otherwise, you can&#039;t redim preserve it.<BR><BR> ReDim Preserve ExpArray(6,cInt(ArrayPos)-1) <BR>


  5. #5
    Join Date
    Dec 1969
    Posts
    717

    Default RE: Must be like this...

    Okay... but that won&#039;t help me... the second part will always be that length, the first changes depending on a database query. <BR><BR>No worries though, I got a work around... I just have an if statement now that checks if there is anything in the array position and if there isn&#039;t, it just gets skipped over.

  6. #6
    Join Date
    Dec 1969
    Posts
    3,921

    Default Wasn't a suggestion...

    ...that&#039;s the way arrays are handled in VB/VBScript. You can still do the same thing, you just have to make the right most element the dynamicly changing dimension. Your current code is not supported in VB/Script if you intend to preserve the contents of the array while redimming

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •