VBScript Operators


Arithmetic Operators

           1.     Addition (+)

A = 15, B = 10
A + B = 25
Note: If A and B are strings, “+” operator works as Concatenate operator.

            2.     Subtraction (-)

A = 15, B = 10
A - B = 5

            3.     Multiplication (*)

A = 10, B = 15
A * B = 150

            4.     Division (/, \)

A = 15, B = 10
A / B = 1.5
A \ B = 1 (“\” return only Quotient)

            5.     Modulus (MOD)

A = 15, B = 10
A MOD B = 1.5 (“MOD” returns remainder)

            6.     Exponentiation (^)

A = 15, B = 2
A ^ B = 225 (“^” returns “the power of”)

             7.     Concatenation (&)

A = 15, B = 2
A & B = 152


Comparison Operators

1.     “==”: Compares if two values are equal or not.
A = 10
B = 20
A == B will be false

2.     <>”: Compares if two values are unequal or not.
A = 10
B = 20
A <> B will be true

3.     >”: Compares if left value is greater than right value.
A = 10
B = 20
A > B will be false

4.     “<”: Compares if left value is less than right value.
A = 10
B = 20
A < B will be true

5.     “>=”: Compares if left value is greater than or equal to right value.
A = 10
B = 20
A >= B will be false

6.     “<=”: Compares if left value is less than or equal to right value
A = 10
B = 20
A <= B will be true


Logical Operators

1.     NOT: Changes true to false, and false to true.
2.     AND: Returns true if both conditions are true.
3.     OR: Returns true if anyone condition is true.
4.     XOR: Returns true if only one condition is true.

No comments:

Post a Comment