Professional Documents
Culture Documents
COLLEGE OF INFORMATICS
DEPARTMENT OF INFORMATION
TECHNOLOGY./
EVENT
MY NOTE
CHAPTER 3
VB.NET is an object-oriented language and is designed to be easy to learn and use. It is
commonly used for building Windows desktop applications, web applications, and mobile
apps.
A method is a function that is associated with a class or object. It defines a behavior or action
that can be performed on an object. Methods are used to implement the functionality of a
class and can be called on an object to perform a specific task.
CHAPTER 3
When we say that an object is an instance of a class, we mean that the object is a specific
example or occurrence of the class. The class is like a blueprint or template that defines the
properties and methods that an object of that class will have. An object is created by using the
class as a template and specifying values for its properties.
For example, consider a class called "Person". This class might have properties such as
"name", "age", and "address", and methods such as "speak" and "walk". An object of the
Person class would represent a specific person, with their own values for the name, age, and
address properties.
EXAMPLE
CHAPTER 3
Here is an example of a simple Person class in VB.NET:
To create an object of the Person class, you could use code like this:
This would create a new Person object and set its properties to specific values. The object is
an instance of the Person class, meaning that it is a specific example of the class with its own
unique property values. You could then call the Speak and Walk methods on the object to
perform those
CHAPTER 3
NAMESPACE
For example, consider a program that contains two classes called "Customer". Without
namespaces, it would be impossible to have both classes in the same program, as they would
have the same name and the compiler would not be able to distinguish between them.
However, if the classes were placed in different namespaces, they could coexist in the same
program without any problems
CHAPTER 3
DATATYPE in a programming language describes that what type of data a variable can
hold .
In Visual Basic (VB), data types can be divided into two main categories: value types
and reference types.
Value types are data types that store their values directly in memory. When you declare
a variable of a value type, a block of memory is allocated to store the value of the
variable. Value types include the following types:
give full access to object-oriented features,
but they impose some memory and speed overhead for managing and accessing objects
Boolea Byte Char Date Decimal Double Integer Long Short Single
CHAPTER 3
Reference give full access to object-oriented features,
but they impose some memory and speed overhead for managing and accessing objects
are data types that store a reference to an object in memory. When you declare a variable
of a reference type, a block of memory is allocated to store the reference to the object, not
the object itself. Reference types include the following types:
Object String Array Class
Variables are places where information can be stored while a program is running.
Each variable in VB.NET has a specific type,
which determines the size and
layout of the variable's memory;
the range of values that can be stored within that memory.
Variable Naming Rules:
Must begin with a letter.
Can't contain an embedded period or embedded type-declaration character.
Must not exceed 255 characters.
Must be unique within the same scope
CHAPTER 3
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, and procedure or block level
ach variable in the variable list has the following syntax and parts:
variablename[ ( [ boundslist ] ) ] [ As [ New ] datatype ] [ = initializer ]
variablename: is the name of the variable
boundslist: optional. It provides list of bounds of each dimension of an array variable.
New: optional. It creates a new instance of the class when the Dim statement runs.
datatype: Required if Option Strict is On. It specifies the data type of the variable.
initializer: Optional if New is not specified
CHAPTER 3
Declaration statement is a statement that declares a variable, constant, or other program
element and specifies its data type and other characteristics. Declaration statements are
used to define the variables and other elements that a program uses, and they must be
written before the elements can be used in the code.
Branching Statements
These can be either conditional statements (such as If or Select Case) or unconditional
(such as Call and Exit).
CHAPTER 3
HANDLING MOUSE EVENTS
MouseEnter: This event is raised when the mouse pointer enters the bounds of a control. It
is typically used to perform actions such as changing the cursor or highlighting the control.
MouseMove: This event is raised when the mouse pointer moves within the bounds of a
control. It is typically used to perform actions such as updating the position of a tooltip or
tracking the mouse pointer.
MouseHover: This event is raised when the mouse pointer hovers over a control for a
specific amount of time. It is typically used to perform actions such as displaying a tooltip or
showing a context menu.
MouseLeave: This event is raised when the mouse pointer leaves the bounds of a control.
It is typically used to perform actions such as resetting the cursor or turning off highlighting.
UNSTRUCTURED EXCEPTION
In unstructured exception handling, an On Error statement at the
beginning of the code handles all exceptions.
an On Error statement at the beginning of the code handles all exceptions.
Structured exception handling is a mechanism that uses specific language constructs, such as
Try, Catch, and Finally blocks, to handle exceptions.
The Try block contains code that might throw an exception. If an exception is thrown, the
runtime environment looks for a matching Catch block to handle the exception. If a matching
Catch block is found, the code in the block is executed to handle the exception. If no
matching Catch block is found, the exception is propagated up the call stack until it is
handled or the program crashes.
The Finally block contains code that is executed regardless of whether an exception was
thrown. This can be useful for cleaning up resources or performing other tasks that should
always be executed, even if an exception occurs.
Unstructured exception handling, on the other hand, is a mechanism that uses general-
purpose language constructs, such as If statements and Goto statements, to handle exceptions.
Unstructured exception handling is typically used in older programming languages that do
not have specific language constructs for exception handling.
CHAPTER 4
Breakpoints—F9
Breakpoint is used to notify debugger where and when to pause the execution of
program.
You can put a breakpoint in code by just pressing F9 at the front of the line.
Step Over--F10
Step Over will execute the entire method/hole function at a time.
You cannot see how the method was executed.
Step Into--F11
similar to Step Over.
if the current highlighted section is any methods call, the debugger will go
inside the method.
you can see how the method is executing line by line till it returns
See the execution in detail manner.
Step Out --Shift - F11
Using Shift + F11 Return from called function to calling function
CHAPTER 6
ADO is a rich set of classes, interfaces, structures, and enumerated types that
manage data access from various types of data stores such as elational databases,
XML documents, and web services. It supports both connected and disconnected
data access, allowing you to work with data in a variety of ways.
There were many data access technologies available prior to ADO.NET, primarily
the following:
Open Database Connectivity (ODBC)
Data Access Objects (DAO)
Remote Data Objects (RDO)
Active X Data Objects (ADO)
DATA PROVIDER
A data provider is used for
Connecting to a database
Executing commands storing it in a dataset,
Retrieving data
Reading the retrieved data and
Updating the database
To place the data into Dataset to use it further in our application.
CHAPTER 6
The data provider in ADO.NET consists of the following four objects:
1. Connection
is used to set up a connection with a data source.
2. Command
A command is a SQL statement or a stored procedure used to :
Retrieve, insert, delete or modify data in a data source.
Execute SQL statement for SQL Server database.
3. DataReader
Datareader is used to retrieve data from a data source in
a read-only and
forward-only mode.
do not update the data.
4. DataAdapter
This is integral to the working of ADO.NET since data is transferred to and from a
database through a data adapter.
Is a bridge between the Dataset and the Data Source. In ADO.NET, a DataSet is an in-
memory cache of data that can be manipulated and updated independently of the data
source. DataSets are used to represent and manage data in a disconnected manner,
allowing you to work with data without maintaining a constant connection to the data
CHAPTER 6
The .NET Framework provides mainly the following data providers for
ADO.NET :
1. Microsoft SQL Server--provides access to Microsoft SQL Server.
Requires System.Data.SqlClient namespace.
2. OLEDB- provides access to data sources exposed by using OLE DB.
Requires System.Data.OleDb namespace.
3. ODBC-provides access to data sources exposed by ODBC.
Requires System.Data.Odbc namespace.
4. .NET Framework Data Provider for Oracle
It is used for Oracle data sources.
It uses the System.Data.OracleClient namespace.
5. EntityClient Provider
provides data access for Entity Data Model applications.
requires the System.Data.EntityClient namespace.
CHAPTER 6
DATA ADAPTER