VBScript » Operators » =

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.



Examples

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 %>
Explanation:

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.

Language(s): VBScript
Code:
<% ="Apple"="Apple" %>
<% ="aPPle"="ApplE" %>

<% =123=123 %>
<% =5.67=98.7 %>
Output:
True
False

True
False
Explanation:

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

Language(s): VBScript
Code:
<% myfish = "Neon tetra" %>
<% =myfish %>
<% = myfish %>
Output:
Neon tetra
Neon tetra
Explanation:

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.

Language(s): VBScript

See Also: