+= Operator

Adds a number to a variable, or puts together a string with a variable, then changes the variable to the result.

Syntax

variable += expression

Parts

variable
Necessary numeric or string variable
expression
Necessary expression with a data type compatible with variable

Instructions

The two statements that follow operate the same.

variable += expression
variable = variable + expression

Examples

Numeric

x = 30
x += 12
After execution
variablevalue
x42

String

x$ = "Hello"
x$ += " world"
VariableValue
x$"Hello world"

See also