Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ReDim Arrays to alter Dimensions

Status
Not open for further replies.

Fezbro

Technical User
Jul 9, 2002
17
AU
I'm in the process of upgrading several applications created by another person, and have an issue with arrars. In nearly all the programs they wrote, they started off declaring single dimension arrays

Public dtBSTZones() AsDate

and then later in the program may or may not alter them to multi dimensional arrays

ReDimPreserve dtBSTZones(2, intCount)

ReDim can't change the number of arrary in vb.net

Is there any way around / to fix this?
 
Redim preserve (I believe) only works on 1 dimensional arrays. I think you can just Redim them as multi-dimensional, but you'll loose any data. I'm not positive on that though, so you may want to test it out a bit.

Another option would be to replace the array with a collection based object.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Make sure that any of the arrays that will be multi-dimensional are set up as multi-dimensional. For example:

public MyArray(,) as date


so when you ReDim Preserve the number of dimensions is not altered

??

J
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top