Professional Documents
Culture Documents
UNIT. 2 .NET
UNIT. 2 .NET
Control Structures:
conditional statements,
loops,
Arrays:
creating array in vb.net,
Dynamic arrays,
Multi-dimensional arrays,
Jagged Array,
The Array class,
Method of Array Class,
Functions:
defining Function,
Function returning a value,
Recursive function,
Param Arrays,
Passing Array as Function Arguments,
Defining Sub procedures,
Passing Parameters by Value and by reference.
Q1. Write the use of “For Each next” statement. MCA 2022 2no.
Q2. Define dynamic array.
Q3. How to convert Boolean to integer in .NET?
Q1. Write a .net program to check whether the number is even or odd using if-
then-else statement.
Q2. Write a .net program to print number from 30 to 1 using for loop.
Q3. Explain mouse based event with example.
Q1.
Q1. Explain the data type in .net framework. Mca 2020 5th.
Q2.
Q1. What is variables and how the variables are declared in vb.net.
Q2. Define an array, methods and name space in .net framework.
Q1.
Q1. What is dynamic array ? how it is declared? Give example. Msc 2nd 2022.
Q2. Differentiate radio button and check box.
Q1. How to define function in vb.net? explain with suitable example.
Q2.
Q1. What is exception handling? Explain try and catch block with help of
suitable example. Unit 3 ka question.
Or
Give syntax of any two loops used in .net. write a program to check whether a
given number is prime or not.
They play a crucial role in designing the user interface (UI) and implementing various
features in VB.NET applications.
controls,
VB.NET Controls are the pillars that help in creating a GUI Based
Applications in VB.Net quickly and easily.
These are objects that you can drag to the Form using the
Control toolbox in the IDE.
Controls enable user interaction and can display information.
2. RadioButton(RadioButton Control):
Radio button is one of the popular way to limiting the user to pick just
on option.
These buttons are grouped together.
3. Label(Label Control):
It is used to show any text to the user, typically the text in a label does
not change while the application is running.
4. TextBox(TextBox Control):
It is used to accept textual input from the user.
5. CheckBox(CheckBox Control):
heckboxes are similar to radio buttons in the way that they
are also used in groups, however, a user can select more than
one item in the group.
6. ListBox(ListBox Control):
Display a list of items, and user can select one or more items.
Useful for displaying list of options or items.
7. ComboBox(ComboBox Control):
Provides a drop-down list of items for the user to select.
Data types,
In Visual Basic .NET (VB.NET), data types are used to declare variables and define
the type of data that a variable can hold.
VB.NET supports a variety of data types, including primitive data types, user-
defined types, and object types.
Syntax:
Variable Declaration
In VB.NET, the declaration of a variable involves giving the variable a name
and defining the data type to which it belongs.
In the above syntax, Variable_Name is the variable name while Data_Type is the
name to which the variable belongs.
Dim x As Integer
Constant,
Enumerations,
Declaring Enumeration,
Type conversions,
In VB.NET, type conversions allow you to convert a value from one data type to
another.
1. Implicit Conversions(Widening):
Implicit conversions are performed automatically by the compiler when there is no
risk of data loss.
2. Explicit Conversions(Widening):
Explicit conversions require the developer to explicitly specify the conversion. These
conversions may result in data loss.
The symbol + and - are the Operators, and the 3, 2, and 1 are operands.
o Arithmetic Operators
o Assignment Operators
o Comparison Operators
o Logical and Bitwise Operators
o Bit Shift Operators
o Concatenation Operators
o Miscellaneous Operators
1. Arithmetic Operators:
Arithmetic Operators are used to perform mathematical
operations such as addition, subtraction, multiplication, division
etc.
+ Addition X+Y
- subtractions X-Y
* multiplication X*Y
/ division X/Y
Mod X Mod Y
2. Assignment Operators:
Assignment operators are used to assign the value to variables.
Some assignment operators are:
Operator Name Example
3. Comparison Operators
= Is equal to (A = B)
Else FALSE
< Less than (A < B); if the condition is true, returns
TRUE else FALSE
And True if both the operands are true (A And B), result
= False
Or
Not(A And B) is
True
AndAlso A AndAlso B =
False
Operator Description
<< The Binary Left Shift Operator is used to shift the bit to the left
side.
>> The Binary Right Shift Operator is used to shift the bit to the right
side.
6. Concatenation Operators:
& It is an ampersand symbol that is used to bind two Result = Wel &
or more operand together. come,
Result =
Welcome
7. Miscellaneous Operators:
o If-Then Statement
o If-Then Else Statement
o If-Then ElseIf Statement
o Select Case Statement
o Nested Select Case Statements
If-Then Statement
Executes a block of code if a specified condition is true.
Syntax:
If-Then-Else Statement
Executes one block of code if a specified condition is true and
another block if the condition is false.
If-Then-ElseIf statement
Checks multiple conditions sequentially and executes the block of
code corresponding to the first true condition.
A loop is also used to reduce the program complexity, easy to understand, and easy
to debug.
Types of Loops
There are five types of loops available in VB.NET:
o Do While Loop
o For Next Loop
o For Each Loop
o While End Loop
o With End Loop
Do While Loop
In VB.NET, Do While loop is used to execute blocks of statements in the program, as
long as the condition remains true.
Syntax:
For Next Loop
A For Next loop is used to repeatedly execute a sequence of code
or a block of code until a given condition is satisfied.
Syntax:
Syntax:
A Dynamic Array can be resized according to the program's requirements at run time
using the "ReDim" statement.
Jagged Array,
A jagged array is an array of arrays, where each element of the
main array is an array itself.
Unlike a multi-dimensional array, jagged arrays can have different
lengths for each row.
Creating a Jagged array:
Syntax:
Example:
The Array class,
Method of Array Class,
Functions:
In VB.NET, functions are block of code that perform a specific task
and return a value to calling code.
Functions are defined using the ‘Function’ keyword.
Functions are also useful to code reusability by reducing the duplicity
of the code.
defining Function,
The syntax to define a function is:
Example:
Param Arrays,
Passing Array as Function Arguments,
Defining Sub procedures,
Passing Parameters by Value and by reference.