The CitectVBA assignment operator uses the equals character ( = ) in a CitectVBA statement. The variable named to the left side of the assignment operator is assigned the operand value from the right side of the assignment operator, as shown here:
' declares integer variable named X
Dim X As Integer
' declares integer variable named Y
Dim Y as Integer
X = 123 ' assigns numeric value 123 to variable X
Y = X ' assigns value of variable X to variable Y
Only one variable can be assigned at any one time with the assignment operator.
There must be a space on either side of the assignment operator, or the equals character may be confused with either the variable name or the value being assigned, and a compile error may occur.
Unless the variable is a variant data type, the value being assigned must be the same data type as the variable receiving the assigned value. For instance, if you assign a text string into a long data type variable, you'll cause an error to occur.
The variable must be previously declared before being assigned a value. The value of a variable can be changed any number of times in a later statements, as in the following CitectVBA example:
' declare integer variable named X
' and assign an initial numeric value of 123 to it
Dim X = 123 As Integer
' reassign X to store the numeric value 456
X = 456
' reassign X to store the numeric value 789
X = 789