In order to have the
object_variable valid, the referred object type must correspond with the variable object type. After assigned, the variable will be of the
Object type.
The
Dim or
ReDim statements only declare a variable that refers to the object. No actual object is referred to until you use the
Set statement to assign a specific object.
Generally, when you use
Set to assign an object reference to a variable, no copy of the object is created for that variable. Instead, a reference to the object is created. More than one object variable can refer to the same object. Because these variables are references to (rather than copies of) the object, any change in the object is reflected in all variables that refer to it.
In the PROMOTIC system scripts, it is possible to create a variable also by the
#pragma variable directive, that allows to create a varible with special predefined value (e.g. object referrence, text in current language, etc.). For a varible created such way the statement
Dim and
Set are not used.
For similar purpose in the
JavaScript language is used the statement
var.