Monday, April 12, 2010

VB Scripting - Operators

Previous12345678910Next

What is the need for Operators?


Operators in VB Script are to used to perform some operations or do some manipulation on variables or values. Operator is a notation to perform operation and this operation will happen on one or more operands.


Operators in VB script can be classified in to mainly four. They are

  • Arithmetic Operators.
  • Logical Operators.
  • Relational or Comparison Operators.
  • Concatenation Operator.

  • VB Script – Arithmetic Operators


    Arithmetic operators are used for arithmetic operations or mathematical operations such as Addition, Subtraction, Multiplication and other kinds of operations.
    Please find the list of Operators with some examples for easy understanding.

    Operator English MeaningExample Result
    + Add 5+27
    - Subtract 5-23
    * Multiply 5*210
    / Floating Point Division 5/22.5
    \Integer Division5\22
    ^ Exponent 5^225
    Mod Modulus 5 Mod 2 1

    Logical Operators


    Logical operators are used to perform logical operations. They are used to manipulate statements or create logical expressions. The Logical operators are AND, OR and NOT.
    Please find the list of Operators with some examples for easy understanding.

    Operator English MeaningExample Result
    Not Inverts Value Not False True
    Or Either Can Be True True or False True
    And Both Must Be True True And False False

    Relational or Comparison Operators


    Relational operators are also called as comparative operators like if we want to compare numbers etc. Generally they are used in conditional statements like IF Else or While loops.
    Please find the list of Operators with some examples for easy understanding.

    Operator English MeaningExample Result
    = Equal To 20 = 45False
    > Greater Than 20 > 45 False
    < Less Than 20 <>True
    >= Greater Than or Equal To 20 >= 45False
    <= Less Than or Equal To 20 <= 45 True
    <>Not Equal To 20 <> 45 True

    Concatenation Operator


    In order to combine two strings and display as a single string we use Concatenation Operator (&). We use “&” to join two expressions.
    Please find below the description with examples for easy understanding.

    Operator English MeaningExample Result
    &Join or Connect"Hello" & "World"Hello World


    Previous12345678910Next

No comments:

Post a Comment