| << D.2.1- Assignment operator | AppendixD | D.2.3- Concatenation operators >> |
Arithmetic operators
The arithmetic operators are all used to calculate a numeric value, and are normally used in conjunction with the assignment operator and/or one of the comparison operators; they are listed in order of Operator Precedence.
|
^ |
Name
Description
Syntax
Example |
Exponentiation
Raises a number to the power of an exponent.
Result = number ^ exponent
number and exponent is any valid numeric expression.
MsgBox 5 ^ 5
MsgBox displays 3125, which is the result of raising the number 5 to the exponent 5.
|
|
* |
Name
Description
Syntax
Example
|
Multiplication
Multiplies two numbers.
Result = number1 * number2
number1 and number2 is any valid numeric expression.
MsgBox 5 * 5
MsgBox displays 25, which is the result of multiplying the number 5 by 5.
|
|
/ |
Name
Description
Syntax
Example |
Floating Point Division
Returns a floating point result when dividing two numbers.
Result = number1 / number2
number1 and number2 is any valid numeric expression.
MsgBox 5 / 4
MsgBox displays 1.25, which is the result of dividing the number 5 by 4.
|
|
\ |
Name
Description
Syntax
Example
Note
|
Integer Division
Returns the integer part of the result when dividing two numbers.
Result = number1 \ number2
number1 and number2 is any valid numeric expression.
MsgBox 5 \ 4
MsgBox displays
1, which is the integer part of the result, when dividing the number 5
with 4. The numeric expressions are rounded to Byte, Integer, or Long subtype expressions, before the integer division is performed. They are rounded to the smallest possible subtype, i.e. a value of 255 will be rounded to a Byte, and 256 will be rounded to an Integer and so on.
|
|
Name
Description
Syntax
Example
|
Modulus Division
Returns the remainder when dividing two numbers.
Result = number1 Mod number2
number1 and number2 is any valid numeric expression.
MsgBox 5 Mod 4
MsgBox displays 1, which is the remainder part of the result, when dividing the number 5 with 4.
|
|
Note |
The numeric expressions are
rounded to Byte, Integer,
or Long subtype expressions, before the modulus
division is performed. They are rounded to the smallest possible subtype,
i.e. a value of 255 will
|
|
Name
Description
Syntax
Example
Note |
Addition
Sums two expressions.
Result = expression1 + expression2
expression1 and expression2 is any valid numeric expression.
MsgBox 5 + 5
MsgBox displays 10, which is the result of adding the expression 5 to 5.
If one or both expressions are numeric, the expressions will be summed, but if both expressions are strings, they will be concatenated. This is important to understand, especially if you have a Java background, in order to avoid runtime errors. In general use the &operator (see under Concatenation Operators), when concatenating and the + operator when dealing with numbers.
|
|
- |
Name
Description
Syntax (1)
Example (1)
Syntax (2)
Example (2) |
Subtraction
Subtracts one number from another or indicates the negative value of an expression.
Result = number1 – number2
number1 and number2 is any valid numeric expression.
MsgBox 5 - 4
MsgBox displays 1, which is the result of subtracting the number 4 from 5.
-number
number is any valid numeric expression.
MsgBox -(5 - 4)
MsgBox displays -1, which
is the result of subtracting the number 4 from 5 and using the unary negation
operator |
| << D.2.1- Assignment operator | AppendixD | D.2.3- Concatenation operators >> |

RSS
