Results 1 to 3 of 3

Thread: Help with the ReDim command (please!)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    84
    I have an array:

    Dim MyArray (1 to 20, 9)

    How can a Rediminsion the first part of the array?

    Later in the code, I need to increase it's size to an unknown amount: (1 to X, 9)

    The '9' never needs to change........ I tried a few different ways of using the ReDim statement, but none have worked.

    BTW - I assume you don't loose data already stored when you do this?

    Thanks for any help.

  2. #2
    Junior Member
    Join Date
    Sep 2000
    Posts
    25
    Actually you WILL lose data preforming a re-dimension this way. The proper way to re-dim an array follows :

    Dim x() as string
    Dim counter as long

    for counter = 0 to 100
    redim preserve x(counter)
    x(Counter) = cstr(Counter) '(or whatever value you want)
    next counter

    Hope this helps.....
    Jim Hubbard
    • VB
    • ASP
    • MS SQL Server

    Hubbard Software Corporation
    [email protected]

  3. #3
    Frenzied Member
    Join Date
    Jul 1999
    Location
    Huntingdon Valley, PA 19006
    Posts
    1,151

    Switch dimensions.

    You can ReDim the last dimension without losing data.

    Can you rewrite the code to allow the dimension you want to change to be the last one?
    Live long & prosper.

    The Dinosaur from prehistoric era prior to computers.

    Eschew obfuscation!
    If a billion people believe a foolish idea, it is still a foolish idea!
    VB.net 2010 Express
    64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.

Posting Permissions

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



Click Here to Expand Forum to Full Width