Go to: Articles List

Arrays How To Part 1 : The Basics
Part 1 | Part 2 | Part 3 | Part 4

Arrays in ASP have a zero based index. This means that the first item in the array is myArray(0). The size of arrays in ASP can be changed while still maintaining the data that is currently in them by using the following syntax:

Dim myArray(1)
myArray(0) = "this"
myArray(1) = "that"
ReDim Preserve myArray(2)
myArray(2) = "theother"

In doing this elements 0 and 1 are saved while enlarging the array.

How to create:

Dim myArray(20)

How to enlarge:

ReDim Preserve myArray(3)

NOTE: If you are creating a small array you can also create it like this:

Dim FavoriteFoodArray
FavoriteFoodArray = Array("green eggs","greasy burgers","chili fries")