ReDim Statement

 

ReDim varname(subscripts)[As Type][,varname(subscripts)]

 

Used to declare dynamic arrays and reallocate storage space.

 

The ReDim statement is used to size or resize a dynamic array that has already been declared using the Dim statement with empty parentheses.  You can use the ReDim statement to repeatedly change the number of elements in and array but not to change the number of dimensions in an array or the type of the elements in the array.

 

 

Example:

 

Sub Main

 

Dim TestArray() As Integer

Dim I

ReDim TestArray(10)

For I = 1 To 10

      TestArray(I) = I + 10

      Print TestArray(I)

Next I

 

End Sub