Search notes:
VBA: variables
A variable has a
datatype
.
The address in memory where the value of a variable is stored is returned with the function
varPtr(var)
.
Lifetime of variables
The time between the creation and destruction of a variable is the variable's lifetime (aka
extent
).
There are five lifetimes for variables
Program extent: variable is defined by
host application
or
VBA specification
Module extent: which also include
static local variables
within a
sub or function
.
Procedure extent:
Object
extent
Aggregate extent: in
UDTs
Declaring variables
dim statement
The
dim
statement declares a variable that is
local to a
sub or function
local to a
module
global statement
A variable can be declared
global
at module level in which case the variable is accessible from other modules as well.
See also
In order to make sure that variables are declared (
dim
statement),
option expclicit
can be used.
Null and nothing etc.
Index