Declaring a Fixed Array

You can declare a fixed array using the Dim statement.
It is good practice to always declare your arrays with an explicit data type.
This line creates an array with six elements.
All VBA arrays (by default) start at zero.
This array has the following elements: myArray(0), myArray(1), myArray(2), myArray(3), myArray(4) and myArray(5).

Dim myArray(5) As Integer 

Default Values

After declaring an array it will contain default values.
Numeric arrays will contain the number 0.
String arrays will contain the empty sting "".
Variant arrays will contain the Empty keyword.
Object arrays will contain the Nothing keyword.

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext