Results 1 to 3 of 3

Thread: redim question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Location
    Porto Alegre, RS
    Posts
    210

    redim question

    when i do a redim of an array, to raise the size, what happen with the data containing in the array, it loses?

    i have an array based on the data from my DB, and i want to do a methode that verifys if there are new data, and if it have something, add to the array.
    if some data is deleted i won´t lower the size, i just won´t use that object of the array anymore.

    Thank you,
    Guilherme Costa

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    Adds an extra space on the end of an array
    Code:
    Redim Preserve MyArray(ubound(MyArray)+1)
    You can use dataset objects in .Net, but if you want a simple storage place then look into using a collection instead, its more flexible and quick to access if you use keys.

  3. #3
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    The following statement resizes the array but saves the contents of the elements.
    ReDim Preserve MyArray(15) ' Resize to 16 elements.


    Full details in the microsoft vb.net help files under "Redim"
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

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