Operators
Operators
NET
www.ustudy.in
Introduction
www.ustudy.in
VB.NET Operators
Arithmetic operators
Comparison operators
Logical operators
Concatenation operators
www.ustudy.in
Arithmetic operators
www.ustudy.in
Example:
Operator Purpose Output
Let a=10
+ Addition b=a+5 55
- Subtraction c=a–5 45
* Multiplication d = a * 10 500
/ Division e=a/6 8.33
Division (integer
\ part only given as f=a\6 8
output)
Modulas
MOD (Remainder after g = a mod 7 1
division)
^ Power h = a^2 2500
= Assignment m = 100
www.ustudy.in
Comparison operators
values.
following table.
www.ustudy.in
Example:
Operator Purpose Output
Let a=50
Check if a value is Dim b As Boolean
= FALSE
equal to another b=(a=55)
Check if a value is
<> b=(a<>55) TRUE
not equal to another
Check if a value is
> b=(a>100) FALSE
greater than another
Check if a value is
< b=(a<100) TRUE
less than another
Check if a value is
>= greater than or b=(a>=50) TRUE
equal to another
Check if a value is
<= less than or equal to b=(a<=75) TRUE
another
Check if a string Dim P As string
LIKE matches a given P=“Good” FALSE
pattern b=(“God” LIKE P)
Check if two object
IS references refer to a
www.ustudy.in same object.
Logical operators
www.ustudy.in
AND
This operator is used as a conjunction of two conditions. The
are true.
Syntax:
www.ustudy.in
Result of AND operation table
www.ustudy.in
Example of AND Operator
Dim a, b, c As Integer
Dim d As Boolean
a = 10
b = 20
c = 30
false.
Syntax:
www.ustudy.in
Result of OR operation table
www.ustudy.in
Example of OR Operator
Dim a, b, c As Integer
Dim d As Boolean
a = 10
b = 20
c = 30
Syntax:
www.ustudy.in
Result of XOR operation table
www.ustudy.in
Example of XOR Operator
Dim a, b, c As Integer
Dim d As Boolean
a = 10
b = 20
c = 30
a boolean expression.
Syntax:
www.ustudy.in
Result of NOT operation table
TRUE FALSE
FALSE TRUE
www.ustudy.in
Example of XOR Operator
Dim a, b, c As Integer
Dim d As Boolean
a = 10
b = 20
www.ustudy.in
AndAlso
This operator is same as AND operator but if the first condition
result is false.
Syntax:
www.ustudy.in
OrElse
This operator is same as OR operator but if the first condition
is true then the second condition is not checked and the result
is True.
Syntax:
www.ustudy.in
Concatenation operators
VB.NET.
www.ustudy.in
Example of concatenation operators
MsgBox(“Good” & “Night”) „Returns GoodNight‟
www.ustudy.in
The End
www.ustudy.in