Dynamic Multi-Dimensional Arrays

Results 1 to 5 of 5

Thread: Dynamic Multi-Dimensional Arrays

  1. #1
    rlasker Guest

    Default Dynamic Multi-Dimensional Arrays

    I need to be able to create a dynamic multi-dimensional array.<BR><BR>If I declare an empty array:<BR>Dim tmpArray()<BR><BR>Then go to ReDim it as Multi-Dimensional with a variable:<BR>Redim Preserve tmpArray(intCount,1)<BR><BR>I get "Subscript out of range"<BR><BR>If I set the multi-array:<BR>Dim tmpArray(0,0)<BR><BR>Then go to ReDim it as Multi-Dimensional with a variable:<BR>Redim Preserve tmpArray(intCount,1)<BR><BR>I get "This array is fixed or temporarily locked"<BR><BR>Is there a way to create a Dynamic Multi-Dimensional Array or at least some sort of work around? I know that my Array will always be like this.<BR>tmpArray(SomeUnknownNumber,1)

  2. #2
    ummmmmmmm Guest

    Default RE: Dynamic Multi-Dimensional Arrays

    The documentation is pretty clear on this:<BR><BR>Preserve - Preserves the data in an existing array when you change the size of the last dimension.<BR><BR>

  3. #3
    ummmmm Guest

    Default Here's some more from the manual

    If you use the Preserve keyword, you can resize only the last array dimension, and you can&#039;t change the number of dimensions at all. For example, if your array has only one dimension, you can resize that dimension because it is the last and only dimension. However, if your array has two or more dimensions, you can change the size of only the last dimension and still preserve the contents of the array.

  4. #4
    rlasker Guest

    Default How to get around this?

    Since I don&#039;t know from the outset how many records will be passed into my page is it possible to use a multi-dimensional array?<BR><BR>Or, should I look to a different solution.<BR><BR>Thanks for your quick reply. What book are you reading from?

  5. #5
    Join Date
    Dec 1969

    Default RE: How to get around this?

    If it&#039;s just a matter of the number of records, a 2d array should be fine. You should know the number of columns in the recordset.<BR><BR>So:<BR><BR>Dim arrayQ(numcolumns,0)<BR>Then, reDim with Preserve the last index until you run out of records.<BR><BR>Check out the QueryString method. Does it automatically for you.

Posting Permissions

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