A special symbol that provides certain process according to requirement is known as operator.
Information is not extremely useful if you can’t do anything with it. Operators perform actions on values, producing a result. For example, the addition operator (+) takes two numbers and adds them together.
It has mainly two types of operator:
1. Unary operator
2. Binary operator
Unary Operator
An operator that acts on one operand is called a unary operator.
Example: -10
Binary Operator
An operator that acts on two operands is called a unary operator.
Example: 15 - 10
It has some sub operators:
1. Arithmetic operators
2. Comparison operators
3. Logical operators
4. Concatenation operators
5. Miscellaneous operators
Arithmetic Operators
Purpose: To perform arithmetic process
Operators | Symbol |
Addition | + |
Subtraction | - |
Multiplication | * |
Division | / |
Modulus | Mod |
Equal to | = |
Relational Operators
Purpose: To compare values, expression or variable for taking decision and other process.
Operators | Symbol |
Less than | < |
Less than equal to | <= |
Greater than | > |
Greater than equal to | >= |
Not equal to | != |
Logical/Bitwise Operators
Purpose: To set some boundary according to a specific condition.
Operators | Symbol |
AND (compulsory True) | and |
OR (Optional any one) | Or |
AND ALSO (If first is false then no further checking will be performed) | and also |
OR ELSE (If first expression is true, then no further checking) | or else |
Example: and also
Dim a = 10, b AsInteger = 20
If a < 5 AndAlso b > 10 Then
Label1.Text = "Match"
Else
Label1.Text = "Not match"
EndIf
Example: or else
Dim a = 10, b AsInteger = 20
If a > 4AndAlso b > 10 Then
Label1.Text = "Match"
Else
Label1.Text = "Not match"
EndIfc
Concatenation Operators
Purpose: To join two or more String
It uses “&”and “+” operator to perform its task.
Example:
Msgbox(“First name = “ & textbox1.text & “ Middle name = “ & textbox2.text )
Miscellaneous Operators
Purpose: For special operation or process
1. Shorthand operators
a += 6 means a = a + 6
a -= 6 means a = a - 6
a *= 6 means a = a * 6
a /= 6 means a = a / 6
Note:In .net a++ (postfix) and ++a (prefix) is not available.
2. Datatype presenter
gettype()
Example:
Dim a as integer
msgBox(a.GetType().ToString)
It will print System.Int32
Posted By: Chaudhary Amit V.
Comments
Post a Comment