ASPFAQs.com
Your source for ASP-related frequently asked questions and answers!


4GuysFromRolla.com : ASP FAQS : Arrays

Question: How do I dynamically resize an array?

Answer: An array can be resized with the Redim statement. The Redim statement takes the following form:

Redim [Preserve] varname(subscripts)

The Preserve should be used if your array contains information that you do not wish to lose when you resize the array. However, if you use the Preserve keyword you can only resize the last dimension of the array; furthermore, use of the Preserve keyword prevents you can't from altering the number of dimensions in the array. (Of course the Preserve won't save the excess arrray information if you specify a smaller size than the orginal array.)

An example of using the Redim statement can be seen below:

'MyArray has five elements
Dim MyArray(5)

'Resize MyArray so it has 10 elements
ReDim MyArray(10)

To learn more about Redim, read the technical documents.


FAQ posted by Scott Mitchell at 9/23/2000 7:53:10 PM to the Arrays category. This FAQ has been viewed 71,897 times.


Copyright 2017 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers