Thursday, May 5, 2011

Visual Basic Operators



1.        Arithmetic. Operators
2.        String -Concatentate Operators
3.        Comparison Operators
4.        Logical Operators
     
Arithmetic. Operators

Operator       Operation
        ^              Exponentiation
       * /             Multiplication and division
         \               Integer division (truncates)
     Mod           Modulus
       + -             Addition and subutraction
     
Parentheses around expressions can change precedence.

String -Concatentate Operators

   To concatentate two strings, use the & symbol or the + symbol:
     
lblTime.Caption = "The current time is" & Format(Now, “hh:mm”)
txtSample.Text = "Hook this “ + “to this”

·         There are six comparison operators in Visual Basic:

Operator       Comparison
        >              Greater than
        <              Less than
       >=             Greater than or equal to
       <=             Less than or equal to
        =              Equal to
       <>             Not equal to

   The result of a comparison operation is a Boolean value (True or False).




   Three logical operators
     
Operator       Operation
      Not            Logical not
     And           Logical and
       Or             Logical or
     
   The Not operator simply negates an operand.
     
   The And operator returns a True if both operands are True. Else, it returns a False.

   The Or operator returns a True if either of its operands is True, else it returns a False.
     
·         Logical operators follow arithmetic operators in precedence.

No comments:

Post a Comment