Operator (+)

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Core Language > Operators > Arithmetic >

Operator (+)

 

Description

 

Used to sum two numbers or concatenate two strings.

 

Syntax

 

result = expression1 + expression2

 

The + operator syntax has these parts:

 

PartDescription
resultAny variable.
expression1Any expression.
expression2Any expression.

 

Returns

 

N/A

 

Remarks

 

Although you can also use the + operator to concatenate two character strings, you should use the & operator for concatenation to eliminate ambiguity and provide self-documenting code.

 

When you use the + operator, addition or string concatenation will occur based on result type:

 

IfThen
Result is numericAdd
Result is stringConcatenate

 

Restrictions

 

See also

 

Examples

 

DIM MyString AS STRING

DIM MyNumber AS LONG

 

'Results will be the string '123'

MyString = 1 + 2 + 3

MyString = 1 & 2 & 3

 

'Result will be the number 6

MyNumber = 1 + 2 + 3