 # VBScript Operators

Operators are used to "do operations" or manipulate variables and values. For example, addition is an example of a mathematical operator and concatenation is an example of a string operator. The plus sign "+" is the operator used in programming language to represent this mathematical addition operation.

VBScript's many operators can be separated into four semi-distinct categories:

• Math Operators
• Comparison Operators
• Logic Operators
• String Concatenation Operator

# VBScript Operators: Math

When you want to perform addition, subtraction, multiplication, and other mathematical operations on numbers and variables use the operators listed below.

Operator English Example Result
+ Add 8+7 15
- Subtract 11-10 1
* Multiply 7*8 56
/ Divide 8/2 4
^ Exponent 2^4 16
Mod Modulus 15 Mod 10 5

# VBScript Operators: Comparison

When you want to compare two numbers to see which is bigger, if they're equal, or some other type of relationship use the comparison operators listed below. Common uses of comparison operators are within conditional statements like an If Statement or the condition check in a While Loop.

Operator English Example Result
= Equal To 10 =1 4 False
> Greater Than 10 > 14 False
< Less Than 10 < 14 True
>= Greater Than Or Equal To 10 >= 14 False
<= Less Than Or Equal To 10 <= 14 True
<> Not Equal To 10 <> 14 5

# VBScript Operators: Logic

Logic operators are used to manipulate and create logical statements. For example if you wanted a variable shoeSize to be equal to 10 or 11 then you would do something like:

## VBScript Code:

```<script type="text/vbscript">
Dim shoeSize
shoeSize = 10
If shoeSize = 10 Or shoeSize = 12 Then
'Some code
EndIf

</script>
```

A detailed explanation of Logic and Logic Operators are beyond the scope of this tutorial, but we do have a list of the various logic operators available to you in VBScript.

Operator English Example Result
Not Inverts Truth Value Not False True
Or Either Can Be True True Or False True
And Both Must Be True True And False False

# VBScript String Concatenation Operator

When you have various strings that you would like to combine into one string use the concatenation operator. The concatenation operator acts as a glue between the two or more strings you wish to attach, effectively making them into one string. String concatenation is often used when using the document.write function.

Operator English Example Result
& Connected To "Hello" & " there" "Hello there"

Be sure to bookmark this page so that you can use it as a reference if you forget the various operators available in VBScript.

# Found Something Wrong in this Lesson?

Report a Bug or Comment on This Lesson - Your input is what keeps Tizag improving with time!

 Web Reference HTML Reference CSS Reference CSS Examples PHP Examples Help Tizag Grow Link to Tizag Tizag.com Store
 Advertise Here More Tutorials! Microsoft Office Tutorials Artist Tutorials