Damini

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 27

BASIC OF VB .

NET

SUBMITTED TO:MRS.JASDEEP KAUR


SUBMITTED BY:DAMINI ASSISTANT PROFESSOR
BCA 6TH SEM DEPARTMENT OF COMPUTER
211521(21048829) APPLICATION
TOPICS

INTRODUCTION
1

2 DATATYPES

3 VARIABLE

4 OPERATORS

5 CONTROL STRUCTURE
INTRODUCTION

• The VB.NET stands for Visual Basic. Network Enabled Technologies. It is a simple, high-level,
object-oriented programming language developed by Microsoft in 2002.

• It is a successor of Visual Basic 6.0, that is implemented on the Microsoft .NET framework.

• Furthermore, it supports the OOPs concept, such as abstraction, encapsulation, inheritance, and
polymorphism.

• Therefore, everything in the VB.NET language is an object, including all primitive data types (Integer,
String, char, long, short, Boolean, etc.), user-defined data types, events, and all objects that inherit
from its base class.

• It is not a case sensitive language, whereas, C++, Java, and C# are case sensitive language.

• This language is used to design user interfaces for window, mobile, and web-based applications
DATATYPES
Data type is used to define the type of a variable or function in a program.

A Data Type refers to which type of data or value is assigning to a variable or function so that a variable can hold
a defined data type value.

Syntax: Dim Variable_Name As Datatype


VARIABLE
A variable is a simple name used to store the value of a specific data type in computer memory. In
VB.NET, each variable has a particular data type that determines the size, range, and fixed space
in computer memory. In simple words , variable is name of memory location and it stores any type
of values.
The Dim statement is used for variable declaration and storage allocation for one or more
variables. The Dim statement is used at module, class, structure, procedure or block level.
Syntax: Dim Variable_Name As Datatype=[value]
Name Descriptions
Dim It is used to declare and allocate the space for one or more variables in memory.

Variable_Name It defines the name of the variable to store the values.


As It is a keyword that allows you to define the data type in the declaration statement.

Data Type It defines a data type that allows variables to store data types such as Char, String, Integer, Decimal,
Long, etc.
Value Assign a value to the variable.
OPERATORS
operator is a special symbol that tells the compiler to perform the specific logical or mathematical
operation on the data values. The data value itself (which can be either a variable or a constant) is
called an operand, and the Operator performs various operations on the operand.

The operands can be integer , floating-point , characters or strings.

For example: 3+2-2 , The symbol + and - are the Operators, and the 3, 2, and 1 are operands.
ARITHEMETIC OPERATOR
The Arithmetic Operators in VB.NET, used to perform mathematical operations such as subtraction,
addition, multiplication, division, etc. on the operands in VB.NET.
For example: A=2 and B=7

Operator Description Example


^ Raises one operand to the power of another B^A will give 49
+ Adds two operands A + B will give 9
- Subtracts second operand from the first A - B will give -5
* Multiplies both operands A * B will give 14
Divides one operand by another and returns a floating point
/ B / A will give 3.5
result

\ Divides one operand by another and returns an integer result B \ A will give 3

MOD Modulus Operator and remainder of after an integer division B MOD A will give 1
RELATIONAL OPERATOR
The Relational Operator is used to compare the value of two variables or operands for the various condition
such as greater, less than or equal, etc. and returns a Boolean value either true or false based on the
condition.
For example: A=10 and B=20
Operator Description Example
Checks if the values of two operands are equal or not; if yes, then
= (A = B) is not true.
condition becomes true.
Checks if the values of two operands are equal or not; if values are not
<> (A <> B) is true.
equal, then condition becomes true.

Checks if the value of left operand is greater than the value of right
> (A > B) is not true.
operand; if yes, then condition becomes true.

Checks if the value of left operand is less than the value of right
< (A < B) is true.
operand; if yes, then condition becomes true.

Checks if the value of left operand is greater than or equal to the value
>= (A >= B) is not true.
of right operand; if yes, then condition becomes true.

Checks if the value of left operand is less than or equal to the value of
<= (A <= B) is true.
right operand; if yes, then condition becomes true.
ASSIGNMENT OPERATOR

The Assignment Operators are used to assign the value to variables in VB.NET.
Operator Description Example
Simple assignment operator, Assigns values from right side operands to left C = A + B will assign value of A + B into
=
side operand C
Add AND assignment operator, It adds right operand to the left operand and
+= C += A is equivalent to C = C + A
assigns the result to left operand
Subtract AND assignment operator, It subtracts right operand from the left
-= C -= A is equivalent to C = C - A
operand and assigns the result to left operand
Multiply AND assignment operator, It multiplies right operand with the left
*= C *= A is equivalent to C = C * A
operand and assigns the result to left operand
Divide AND assignment operator, It divides left operand with the right operand
/= C /= A is equivalent to C = C / A
and assigns the result to left operand (floating point division)
Divide AND assignment operator, It divides left operand with the right operand
\= C \= A is equivalent to C = C \A
and assigns the result to left operand (Integer division)
Exponentiation and assignment operator. It raises the left operand to the power
^= C^=A is equivalent to C = C ^ A
of the right operand and assigns the result to left operand.
<<= Left shift AND assignment operator C <<= 2 is same as C = C << 2
>>= Right shift AND assignment operator C >>= 2 is same as C = C >> 2
Concatenates a String expression to a String variable or property and assigns Str1 &= Str2 is same as
&=
the result to the variable or property. Str1 = Str1 & Str2
LOGICAL OPERATOR
The Logical operators are used to perform test on two relational expressions.
For example: A=True and B=False

Operator Description Example


If both the operands are true, then condition becomes true.
And (A And B) is False.
Otherwise, it returns false.

Or If any of the two operands is true, then condition becomes true. (A Or B) is True.

Not If a condition is true, then Logical NOT operator will make false. Not(A And B) is True.

It returns True if both expressions are True or both expressions are


Xor A Xor B is True.
False; otherwise it returns False
CONTROL STATEMENTS

In VB.NET, the control statements are the statements that controls the execution of the program on the
basis of the specified condition. It is useful for determining whether a condition is true or not. If the
condition is true, a single or block of statement is executed.
CONDITIONAL STATEMENTS
Conditional statements in Visual Basic can be used to take decisions based on certain conditions in your
program.

SELECT CASE
IF-THEN

IF-THEN-ELSE
IF-THEN IF-THEN- SELECT
DEFINITION:
ELSE
DEFINITION:
CASE
DEFINITION:
The If-Then Statement is a control The If-Then Statement can execute The Select Case statement is a
statement that defines one or more single or multiple statements when collection of multiple case
conditions, and if the particular the condition is true, but when the statements, which allows executing
condition is satisfied, it executes a expression evaluates to false, it a single case statement from the list
piece of information or statements. does nothing of statements.

SYNTAX: SYNTAX: SYNTAX:


If condition Then If (Boolean_expression) Then Select Case [variable or expression
[Statement or block of Statement] 'This statement will execute if the B ]
End If oolean condition is true Case value1 'defines the item or val
Else ue that you want to match.
'Optional statement will execute if t // Define a statement to execute
he Boolean condition is false Case value2 'defines the item or val
End If ue that you want to match.
// Define a statement to execute
Case Else
// Define the default statement if no
ne of the conditions is true.
End Select
IF-THEN
IF-THEN-ELSE
SELECT CASE
LOOPING STATEMENTS
A loop statement allows us to execute a statement or group of statements multiple times and
following is the general form of a loop statement in most of the programming languages

DO-LOOP
FOR-NEXT

WHILE-END
WHILE
FOR-NEXT WHILE-END DO-LOOP
WHILE
DEFINITION: DEFINITION: DEFINITION:
For loop most commonly used loop It is a pre test loop, it is used when It is a post test loop, it is used when
because it is simple . we don’t know the number of we want to execute loop body at
It is used when we want to perform iterations in advance. It is also least once even condition is false.it
initialization , condition, and know as entry control loop. is also know as a exit control loop
increment/decrement operation in a
single line.

SYNTAX: SYNTAX: SYNTAX:


For variable_name As [ Datatype ] While [condition] Do
= start To end [ Step step ] [ Statement to be executed ] [ Statements to be executed]
[ Statements to be executed ] End While Loop While Boolean_expression
Next
FOR - NEXT
WHILE-END WHILE
DO-LOOP
THANK
YOU !

You might also like