Adds a number to a variable, or causes concatenation with a string and a variable, then changes the variable to the result.
variable += expression
- A numeric or string variable.
- An expression with a data type compatible with
The two statements that follow operate the same.
variable += expression variable = variable + expression
The element on the left side of
+= can be a scalar variable, a property, or an element of an array.
A property cannot have the modifier
+= adds the numeric value on its right side to the variable or property on its left side.
Then it changes the variable or property on its left side to the result.
You can also use
+= to concatenate the string value on its right side to the variable or property on its left side.
Then it changes the variable or property no differently.
We recommend that you always use
&= if you know that the values are strings.
x = 30 x += 12
x$ = "Hello" x$ += " world"