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!

Basic ? about arrays 2

Status
Not open for further replies.

TheConeHead

Programmer
Aug 14, 2002
2,106
US
I am only finding examples of arrays where you have to specify the length when creating it:

double[] prices = new double[20];

my question: Is there a way to not have to specify the length?? I would like it open-ended? I get an error when I try:

double[] prices = new double[];

[conehead]
 
You can DIM your array with an arbitrary value, then REDIM it later in your code. Use REDIM PRESERVE to keep any items that you have already put into an array.

Here's an article that discusses the performance implications of using REDIM and REDIM PRESERVE, and suggests the use of the ArrayList instead of an Array.

Good Luck!
 
You could use an arraylist (if you want a single demension array).

Code:
Dim myList as new arraylist
myList.Add("adsf")
myList.Add("hey")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top