Initialising

All local variables are automatically initialised to a Default Value when they are declared.
Once a variable has been declared, changing the value later means Assigning a new value.
Unlike a lot of other programming languages you cannot declare and initialise on the same line.


Declare and Initialise

In VBA it is not possible to declare and initialise a variable in one line.
You must declare your variable on one line and then assign the value on a new line.
Explicitly assigning a value to a local variable after it has been declared is recommended.

Using a Colon Separator to put these on one line makes your code harder to read.


Boolean Variables

These default to False


Numeric Variables

Integer, Long, Single, Double and Currency are all initialised to zero.


Variable Length Strings

These are initialised to a zero-length (or empty) string.


Fixed Length Strings

These are initialised with the character represented by the ASCII code 0, or Chr(0).


Variant Variables

These default to Empty


Object Variables

These default to Nothing


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