The Size of an Array Must Be a Constant or a Number Error

When you declare and size an array using a Dim statement, the size of the array must be indicated by either a constant or a number.

# Notes

# Example

Trying to size an array using a variable:

Dim j as Integer
j=5
Dim a(j) as Integer

If you need a variable length array, declare the array as having no bounds and then use the Append method to add elements, such as:

Dim myArray (-1) as Integer
myArray. Append(5)

# See Also

Dim statement.