Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

UNIT ONE

GETTING STARTED WITH VISUAL BASIC


OPERATORS AND DATATYPES
VB.NET OPERATORS
 Arithmetic operators

 Comparison operators

 Logical operators

 Concatenation operators
OPERATORS
 Arithmetic operators are used to perform
arithmetic calculations such as addition and
subtraction.
 Comparison operators are used to compare two or
more values.
 Logical operators are used to perform logical
operations such as AND, OR, NOT on one or more
expressions.
 Concatenation operators are used to join two string
values.
 & and + arethe two concatenation operators
available in VB.NET.
 The operator & is used to concatenate two strings
and + is used to add two numbers and concatenate
two strings.
ARITHMETIC OPERATORS
Operator Purpose Example: 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
\ f=a\6 8
as output)

Modulas
(Remainder after
MOD g = a mod 7 1
division)

^ Power h = a^2 2500


= Assignment m = 100
COMPARISION OPERATORS
Operator Purpose Example: Output
Let a=50
= Check if a value is Dim b As Boolean b=(a=55) FALSE
equal to another

Check if a value is not


equal to another
<> b=(a<>55) TRUE
Check if a value is
greater than another
> b=(a>100) FALSE
< 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 P=“Good”
matches a given b=(“God” LIKE P)
LIKE FALSE
pattern

Check if two object


references refer to a
IS
same object.
COMPARISION OPERATORS
Operator Purpose Example: Output
Let a=50 b
= 40 c = 6
AND Returns true if both (a>b) AND (b<c) FALSE
the operands are
true
OR Returns true if any
(a>b) OR (b<c)
of the operands is
TRUE
true
negates the given value.
NOT truefalse and vice versa NOT(a>b)
FALSE
LOGICAL OPERATORS
DATATYPES
 Data types determine the type of data that any
variable can store.
 There are various data types in VB.NET. They
include:
Datatype Bytes
Boolean Platform dependent.True/False
Byte 1 byte
Char 2 bytes
Date 8 bytes
Integer 4 bytes
Long 8 bytes
String Platform dependent
VARIABLE DECLARATION
Dim VariableName as DataType
Dim x_var as Integer

You might also like