= Operator

Assigns a value to a variable or property.

Syntax

variable = value

Parts

variable
Required. Any modifyable variable or property.
value
Required. Any expression of a type compatible with variable.

Remarks

The element on the left side of the equals sign (=) can be a simple scalar variable, a property, or an array element. The = operator assigns the value on its right to the variable or property on its left.

NoteDo not confuse this = operator with the = comparison operator. For the latter, see the Comparison Operators article.

Because of the language's overloading of this operator, the = operator is the only assignment operator that cannot be chained in a single assignment statement, except as the first. The := operator is much more reliable for this purpose.

Examples

Variable

The following example demonstrates the use of = as an assignment operator and comparison operator in the same statement:

Listing 1
Dim x, y 'x and y are initially zero
x = y = 0 ' y is being tested for equality to zero
After execution
variablevalue
x1
y0

Property

Listing 2
' Change value of property
#obj.value = 42

See also