CitectVBA Programming Reference > Understanding CitectVBA Language Basics > Variables > Variable initialization values

Variable initialization values

CitectVBA variables are initialized when first declared. Numeric variables are initialized to 0 (zero). Variable-length strings are initialized to zero-length strings (""). Fixed length strings are filled with zeros. Variant variables are initialized to Empty.

To be sure of the contents of a variable, a valid value needs to be assigned to it before it is used as a operand in a CitectVBA statement. For details, see Assignment Operator.

Note: Only implicitly declared variables can be assigned an initial value in the declaration. However, as explicit declaration is preferred practice in CitectVBA, explicit variables need to be declared before they can be assigned a value.

Every call to a procedure will reinitialize the value of all objects (except static variables) declared within that procedure.

Note: In CitectVBA, use a static variable, a modular variable, or a CitectSCADA tag to store variable values between procedures. For details, see Scope of CitectVBA.

Objects (including variables) declared in CitectVBA are only initialized when referenced by a running piece of code, and are removed from memory when all references are closed.

In the CitectSCADA multithreaded environment, CitectVBA remains active in memory only so long as a procedure is being processed. At the completion of a CitectVBA procedure, all objects no longer referenced by that procedure are removed from memory. For details, see Multithread Considerations with CitectVBA.

See Also

CitectVBA Data Types

Variable initialization values

Constants

Variant Declaration

Arrays of Variables