vbscript-equal

OPERATOR:   =


Implemented in version 1.0

 =

The operator is used to assign a value to a variable, or to compare strings and numbers, or to print out the value of a variable.

When used for assignment, a single variable on the left side of the = operator is given the value determined by one or more variables and/or expressions on the right side.

Code:
<% mynumber = 5.0 + 7.9*(444.999 / 456.9) %>
<% mystring = « The moon is 2160 miles in diameter. » %>
<% myvar = xxx + yyy + zzz %>
<% myarray(40) = 12345 %>

The = operator can also compare two strings or two numbers and see if they are the same. For strings, the comparison is case sensitive.

Code:
<% = »Apple »= »Apple » %>
<% = »aPPle »= »ApplE » %>

<% =123=123 %>
<% =5.67=98.7 %>

Output:
True
False

True
False

When the = operator is used to print out the value of a variable, the statement must be enclosed by its own set of <% %>. There can blank spaces between the = operator and the variable.

Code:
<% myfish = « Neon tetra » %>
<% =myfish %>
<% = myfish %>

Output:
Neon tetra
Neon tetra

vbscript-plus

OPERATOR: +


Implemented in version 1.0

+

The + operator has two uses. It is used to add numbers together. It also may be used to concatenate (combine) strings together.

Note it is usually recommended that only the & operator be used for string concatenation.

Addition:

Code:
<% total = 5.678 + 0.234 + 23.1 %>

Output:
29.012

Concatenation:

Code:
<% cheese= » is made of blue cheese. » %>
<% sentence= »The moon » + cheese +  » Mice like blue cheese. » %>

Output:
The moon is made of blue cheese. Mice like blue cheese.

vbscript-integer-divide

OPERATOR: \


Implemented in version 1.0

\

The \ operator divides two numbers and returns an integer (fixed-point). Each number can be either floating-point or fixed-point.

This operator works by rounding the values of the supplied operands to integers (if necessary) before performing the calculation and only returns an integer with no decimal representation (truncated).

This first example requires no rounding of the operands and returns ‘6’ (‘6.25’ truncated).

Code:
<% result = 25 \ 4 %>

Output:
6

This next example demonstrates the ‘pre-rounding’ of the operands; the actual values used for the calculation eqate to ’35\6′ which returns ‘5’ (‘5.833r‘ truncated).

Code:
<% result = 35.4 \ 6.01 %>

Output:
5

Compare the previous example to the next which returns ‘6’ because the first operand has been rounded internally to ’36’ before calculation.

Code:
<% result = 35.9 \ 6.01 %>

Output:
6

vbscript-multiply

OPERATOR: &


Implemented in version 1.0

&

The & operator is the preferred operator for concatenating strings. However, the + operator may also be used for concatenation.

Code:
<% cheese= » is made of blue cheese. » %>
<% sentence= »The moon » & cheese &  » Mice like blue cheese. » %>

Output:
The moon is made of blue cheese. Mice like blue cheese.