+ Reply to Thread
Results 1 to 4 of 4

redim preserve

  1. #1

    redim preserve

    hi, ive read through previous threads and im struggling to understand
    dynamic arrays., specifically resizing. Basically Im using a dynamic
    array 2 cols wide with variable rows. Im using ReDim Preserve
    CapturePowers(1 To x, 1 To 2)
    CapturePowers(x, 1) = name
    CapturePowers(x, 2) = 0
    Ive read you can only redim the last array which is were im lost. Im
    assuming in my array that 1 to x is the rows, and 1 to 2 is the cols. I
    can use redim with single arrays fine. I can work out the size Of the
    array before using it and wondering if this is the best option or the
    only option.
    Hope this makes sense
    regards Robert


  2. #2
    Jim Rech
    Guest

    Re: redim preserve

    You seem to have a good handle on this. Your choices are to work out the
    size before or to create the array as 2 rows deep and X columns wide. In
    other words, to transpose it. If you really needed a 'vertical' array you
    could create it from the 'horizontal' array afterwards.

    --
    Jim
    <[email protected]> wrote in message
    news:[email protected]...
    | hi, ive read through previous threads and im struggling to understand
    | dynamic arrays., specifically resizing. Basically Im using a dynamic
    | array 2 cols wide with variable rows. Im using ReDim Preserve
    | CapturePowers(1 To x, 1 To 2)
    | CapturePowers(x, 1) = name
    | CapturePowers(x, 2) = 0
    | Ive read you can only redim the last array which is were im lost. Im
    | assuming in my array that 1 to x is the rows, and 1 to 2 is the cols. I
    | can use redim with single arrays fine. I can work out the size Of the
    | array before using it and wondering if this is the best option or the
    | only option.
    | Hope this makes sense
    | regards Robert
    |



  3. #3
    Charlie
    Guest

    RE: redim preserve

    You can only resize the last DIMENSION of a multi-dimensional array...

    ReDim Preserve CapturePowers(1 To 999, 1 To x)
    ReDim Preserve ThreeDimArray(1 To 999, 1 To 999, 1 To x)

    .... therefore, you can add "columns" but not "rows" It's a pain in the
    butt. You can write a "GridFlip" function to swap rows to columns, add a
    column, and flip columns back to rows!

    "[email protected]" wrote:

    > hi, ive read through previous threads and im struggling to understand
    > dynamic arrays., specifically resizing. Basically Im using a dynamic
    > array 2 cols wide with variable rows. Im using ReDim Preserve
    > CapturePowers(1 To x, 1 To 2)
    > CapturePowers(x, 1) = name
    > CapturePowers(x, 2) = 0
    > Ive read you can only redim the last array which is were im lost. Im
    > assuming in my array that 1 to x is the rows, and 1 to 2 is the cols. I
    > can use redim with single arrays fine. I can work out the size Of the
    > array before using it and wondering if this is the best option or the
    > only option.
    > Hope this makes sense
    > regards Robert
    >
    >


  4. #4

    Re: redim preserve

    Thankyou both for your replies. Ive decided to take the easy way, and
    calculate the array before using it. Easy to do than I thought, thanks
    for advice.
    Regards Robert


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1