# VBScript - The Operators

August 2017

## What is an operator?

Operators are symbols used to manipulate variables, that is to say, perform operations, evaluate, compare ...

## There are several types of operators

• operators to perform calculation
• comparison operators
• logical operators

## The calculation operators

These operators can mathematically change the value of a variable:

Operator Name Effect Example Result (x = 7)
-Subtraction operatorSubtraction two valuesx-34
-Negation operatorUsed with a single operand, it reverses the sign of the variable-x-7
*Multiplication operatorMultiplies two valuesx*321
/Division operatorDivides two valuesx/32.3333333
=Assignment operatoassigns a value to a variablex=3Assign the value 3 to the variable x
^power operatorraise the variable to the specified power xx^249
Mod modulo operator Returns the remainder of division of the left operand to the right of x x Mod 21

## Comparison operators

Operator Name Effect Example Result
= equality operatorCompares two values ??and check their equalityx=3Returns true if X is equal to 3 or false in the other case.
<Relational operator (is smaller than)Checks if a variable is less than a valuex<3Returns true if X is less to 3 or false in the other case.
<=Relational operator (is smaller than or equal)Checks if a variable is less than or equal to a valuex<=3Returns true if X is less or equal to 3 or false in the other case.
>Relational operator (is greater than)Checks if a variable is greater than a valuex>3Returns true if X is greater to 3 or false in the other case.
>=Relational operator (is greater than or equal)Checks if a variable is greater than or equal to a valuex>=3Returns true if X is greater or equal to 3 or false in the other case.
<>Relational operator (is not)Checks if variable is different from a valuex<>3Returns true if X is different from 3.
IsComparaison operator Compares two expressionsexpression1 Is expression2Returns true if the result of the left operand is the same as the one to the right

This type of operator allows you to check if one or more conditions are true:

Opérateur Dénomination Effet Syntaxe
OrOr Check whether one of the conditions is achieved((condition1)Or(condition2))
AndANDVerifies that all conditions are met((condition1)And(condition2))
XorInverse orMake the inverse of the OR ((condition1)Xor(condition2))
EqvEquivalencePerforms an equivalence between two conditions ((condition1)Eqv(condition2))
ImpImplicationChecks a logical implication between two conditions((condition1)Imp(condition2))

## String Operators

The following operators are used to perform operations on strings:

Operator Name Effect Syntax Result
&ConcatenateConcatenate two strings"Hello"&"World""HelloWorld"
LikeCompararaisonCompares two strings"hello" like "goodbye"False

Original document published CommentcaMarche.net.

## Related

Published by jak58. Latest update on March 11, 2013 at 01:12 PM by jak58.