Monday, 21 August 2017

Vb Script Operators

An Operator works either on values or variables to perform some task.Operators are very important in programming  assign values to variables or perform tasks without operators is not possible.
There are mainly three kinds of operators in VB Script: 
  1. Arithmetic
  2. Comparison 
  3. Logical operators.
  4. Concatenation Operator

Arithmetic Operators :

  • + (addition) :The addition Operator is used to find the addition of given numbers,For example 8+2 is equal to 10
  • - (subtraction) :The subtraction Operator is used to find the subtraction of given numbers,For example 10-2 is equal to 8
  • * (multiplication) : The multiplication Operator is used to find the multiplication of given numbers,For example 4*2 is equal to 8
  • / (division) : The division operator is used to find the Quotient.For example 5/2 is equal to 2.
  • % (modulus) :The modulus operator is used to find the remainder after a division. For example, 20%3 is equal to 2
  • ^ (exponentiation) : The exponentiation operator is equivalent to “to the power of” in mathematics. For example, 2^3 is equal to 8.
  • & (concatenation) : The concatenation operator is used to concatenate two string values.For example, Visual&Basic is equal to VisualBasic

Comparison Operators:

Comparison operators are used to compare two values.
Comparision Operator always written a Boolean value,either TRUE or FALSE
  • == (Equal to ) :
  • <> (Not equal to)
  • <  (Less Than )
  • >  (Greater Than)
  • <=  (less than or Equal to )
  • >= (Greater than or Equal to )
 For example,if  you have two variables a and b with values a=4 and b=9 respectively, then the results for the following comparison will be like this:

a==b  will return false.
a<>b will return true.
a<b will return true.
a>b will return false.
a<=b will return true.
a>=b will return false.

Logical operators:

Logical operators are used to perform logical operations.
Logical Operator always written a Boolean value,either TRUE or FALSE


  • AND
  • OR
  • NOT 
  •  XOR


 For example,you have two variables a and b with values true and false respectively, then the results for the following logical operations will be like this:


a AND b  will return false.

a  OR b will return true.
NOT(a  OR b) will return false.
a  XOR b will return true.

Concatenation Operators

Concatenation operators are used to perform Concatenation  operations.
In Vb script we have following concatenation operators

+ : Adds two Values as Variable Values are Numeric

& : Concatenates two Values

If variable A holds 10 and variable B holds 20 then answer will be:
+ :30 
& :1020

No comments:

Post a Comment