Introduction to Visual Basic .
NET
Introduction to Visual Basic .NET
Main Menu 1 of 63
Introduction to Visual Basic .NET
Objective
This chapter will give an introduction to Visual
Studio .NET and Visual Basic .NET along with its
features, development environment and its building
blocks. At the end of this chapter students should be
able to write their first simple application in Visual
Basic .NET.
Main Menu 2 of 63
Introduction to Visual Basic .NET
Scope
Introduction
System Requirements
Visual Studio .NET Features
Visual Basic .NET – Introduction
Features of Visual Basic .NET
Development Environment of Visual Basic .NET
Main Menu 3 of 63
Introduction to Visual Basic .NET
Introduction
.NET Framework covers all the layers of software
development above the operating system. When
using the .NET Framework for the application
development, there is a choice of wide variety of
languages to use.
Microsoft NET Framework SDK is required for
these languages to function which includes the
compilers for all these languages.
Main Menu 4 of 63
Introduction to Visual Basic .NET
Introduction
The overall vision of Microsoft .NET is to create a
common platform for building applications that can
be delivered as reusable, interoperable services over
the Internet and corporate Intranets. Getting there
will require a new programming environment in
which developers are free to mix and match
components from multiple programming languages
to create the computer applications of tomorrow.
Main Menu 5 of 63
Introduction to Visual Basic .NET
System Requirements
Visual Studio comes in four edition namely Visual
Studio .NET Professional Edition, Enterprise
Developer Edition, and Enterprise Architect Edition.
Computer/Processor
PC with Pentium II-class processor, 450 MHz
PC with Pentium III-class processor, 600 MHz
Operating System
MS Windows 2000 Server or Professional
MS Windows XP Professional, NT 4.0 Server
Windows Me and 98
Main Menu 6 of 63
Introduction to Visual Basic .NET
System Requirements
While Visual Studio.NET will install on all the
above platforms, Windows 2000 is required to use
all the features of the .NET framework. Some
features such as GDI+ are only supported in
Windows 2000. In Windows Me and 98 some
features of Visual Studio is not supported.
Memory
Windows 2000 Professional: 96 MB of RAM
Windows 2000 Server: 192 MB of RAM (256 MB
recommended)
Main Menu 7 of 63
Introduction to Visual Basic .NET
System Requirements
Hard Disk
500 MB on System Drive and 2.5 GB on installation
drive
Drive
CD-ROM drive
Display
VGA or higher resolution monitor
Main Menu 8 of 63
Introduction to Visual Basic .NET
Installation of Visual Studio .NET
Visual Studio comes with a Pack of five CDs.,
which contains the setup files needed to complete
the installation of .NET Framework, Visual
Studio.NET and MSDN. The pack also performs
Windows Component Update that ensures that the
operating system meets the minimum requirements.
To start the installation, insert the Installation CD
and run the Setup.EXE program or allow auto run to
kick in from the CD. This brings a dialog box as
shown below
Main Menu 9 of 63
Introduction to Visual Basic .NET
Installation of Visual Studio .NET
Main Menu 10 of 63
Introduction to Visual Basic .NET
Installation of Visual Studio .NET
From this dialog box, choose the Windows
Component Update option. Notice that all other
options are not available. This ensures that the
operating system and software components meet the
minimum requirements.
By clicking the “Windows Component Update”
option it will prompt for Windows Update CD.
Insert the CD labeled with Windows Component
Update and then click OK. This brings a dialog box
as shown below
Main Menu 11 of 63
Introduction to Visual Basic .NET
Installation of Visual Studio .NET
Main Menu 12 of 63
Introduction to Visual Basic .NET
Installation of Visual Studio .NET
From this dialog box, click
Continue. This shows a
screen that asks the
username and password as
shown below to use as the
system is restarted. This is
optional. Actually the
install process of Windows
Component Update requires
multiple reboots.
Main Menu 13 of 63
Introduction to Visual Basic .NET
Installation of Visual Studio .NET
Giving the username and
password in the dialog box
allows the setup program to
automatically log back into
the system after each
reboot. The process of
Install will begin – running
from top to bottom till
complete. The following
windows show the progress
bar indicating the
installation status.
Main Menu 14 of 63
Introduction to Visual Basic .NET
Installation of Visual Studio .NET
While installing the
windows component the
machine will restart after
installing “Windows 2000
Service Pack 2” and
“Microsoft Internet
Explorer 6.0”. When the
Windows Component
Update is complete the
following screen will pop
up.
Main Menu 15 of 63
Introduction to Visual Basic .NET
Installation of Visual Studio .NET
At this point system is
ready to use the .NET
Framework SDK. The
applications can be
developed by using text
editors and can be deployed
and run. Now, the Visual
Studio.NET installation can
be done.
Now, you are taken to the
main installation start
screen. See the figure given
below
Main Menu 16 of 63
Introduction to Visual Basic .NET
Installation of Visual Studio .NET
Click on the link 2 to start
installing the Visual
Studio.NET.
Here a window will appear
asking the Product Key and
to accept a license
agreement at this point for
Visual Studio.NET as
shown below
Main Menu 17 of 63
Introduction to Visual Basic .NET
Installation of Visual Studio .NET
After accepting the license
agreement, click Continue.
Now, a dialog is presented
to choose the different
components of Visual
Studio.NET to install. The
screen looks like as shown
below
Main Menu 18 of 63
Introduction to Visual Basic .NET
Installation of Visual Studio .NET
Click the Install Now
link. The install will
now take some time.
During installation it
shows some status
information as well as a
list of major features of
Visual Studio.NET as
shown in the figure
given below
Main Menu 19 of 63
Introduction to Visual Basic .NET
Installation of Visual Studio .NET
After the installation is
complete, go to the Start
menu, from the Programs
menu, select Microsoft
Visual Studio.NET 7.0.
Further select the same
option to open the Visual
Studio.NET development
environment. This brings
the IDE as shown below
Main Menu 20 of 63
Introduction to Visual Basic .NET
Installation of Visual Studio .NET
From the screen shown
above, existing projects can
be opened or a new project
can be started with the help
of the link provided on the
left side of the screen
namely “Get Started”. On
choosing the option “New
Project” in the Get Started
page, the screen as shown
below will appear from
which the language in
which project is to be done
can be selected. Main Menu 21 of 63
Introduction to Visual Basic .NET
Visual Studio .NET – Features
Visual Studio.NET has a new, almost completely
customizable shell that brings various languages into
a common integrated development environment. The
functionality found in Visual InterDev for web
development, which was separate from Visual
Studio, is now a core part of the environment itself
and is accessible from the various language
products. The common IDE supports high
productivity development via drag and drop visual
designers for HTML, XML, data, server side code
and more.
Main Menu 22 of 63
Introduction to Visual Basic .NET
Visual Studio .NET – Features
The main features can be summarized as follows:
Shared Integrated Development Environment
Visual Studio.NET supports a shared single
integrated development environment for all languages
within it.
Start Page
The Start Page as shown above provides a central
location for setting preferred options, reading product
news, accessing discussions etc.
Based on the development experience, the developers
can quickly customize the look and feel of the IDE.
Main Menu 23 of 63
Introduction to Visual Basic .NET
Solution Explorer
Solution Explorer window can be selected from
View | Solution Explorer
Solution Explorer displays an organized list of
projects as well as the files and directories that are
part of the current solution. The solution can consist
of projects in different languages.
Main Menu 24 of 63
Introduction to Visual Basic .NET
Enhanced Toolbox
This option can be selected from View |
Toolbox
A variety of items that can be used in Visual Studio
projects are displayed in the toolbox. The items
available change depending on which designer or
editor the developer is using. The items can include
Web and Windows based form controls, ActiveX
Controls, Web Services, HTML elements, objects
and items from Clipboard.
Code snippets from the code window can also be
dragged onto the toolbox for later use.
Main Menu 25 of 63
Introduction to Visual Basic .NET
Server Explorer
This Server Explorer window can be opened from
View | Server Explorer
One of the biggest challenges in writing a middle-
tier component is discovering what application
services are available on the corporate network and
after that integrating them into the application.
Server Explorer of Visual Studio.NET shows an
entire computer including databases, message
queues, performance counter services, processes,
event logs and all other installed server elements.
Main Menu 26 of 63
Introduction to Visual Basic .NET
Dynamic Help
This option can be selected from Help |
Dynamic Help
Dynamic Help provides appropriate help on a single
click. It provides pointers to relevant information
specific to the current development task.
Main Menu 27 of 63
Introduction to Visual Basic .NET
Enhanced Intelligence
Web Developers can get immediate help on tags,
properties and even values within the code editor
using the IntelliSense technology. Developer can
gain benefits of automatic statement completion and
syntax notifications when they write their code.
Enhanced Integrated Debugger
End-to-end debugging of web applications across
languages, projects, processes and stored procedures
can be performed from within the IDE.
Main Menu 28 of 63
Introduction to Visual Basic .NET
Command Window
This window can be selected from View | Other
Windows | Command Window
Using the Command Window developers can
directly interact with the IDE, bypassing the menu
system, and avoiding dialog boxes by executing
command parameters, switches and arguments.
Main Menu 29 of 63
Introduction to Visual Basic .NET
Window Management
More code can be viewed on screen at one time
when using Visual Studio.NET.
Auto Hide option allows to hide tool windows along
the edges of the IDE so that valuable space is not
occupied. To view the hidden window, simply place
the mouse over the appropriate tab.
Various information windows in Visual Studio.NET
are dockable.
When developers edit multiple documents in the
editor or designer, all the documents appear as tabs
on the top. Main Menu 30 of 63
Introduction to Visual Basic .NET
Window Management
Back and Forward button allows developers to
navigate through the open windows in the
environment.
Visual Studio.NET provides support for multiple
screens so that more windows can be opened at the
same time without sacrificing screen space.
Links can be added to Web browser Favorites from
within the Visual Studio. This can be done by
selecting View | Other Windows |
Favorites.
Main Menu 31 of 63
Introduction to Visual Basic .NET
Visual Database Tool
For working with databases, VS.NET includes
comprehensive features. From within the VS.NET,
databases and schemas, indexes, triggers and other
items can be created.
The following features can be selected from Tools |
Options | Database Tools
Main Menu 32 of 63
Introduction to Visual Basic .NET
Other Window
Database Designer
It allows working with physical database schemas
for Oracle and SQL Server without leaving the
Visual Studio.
Query Designer
It enables to create complex queries quickly and
easily.
Database Project
All the elements relating to data can be grouped and
placed at one location using the Database Project.
Main Menu 33 of 63
Introduction to Visual Basic .NET
Web Hosting
Developers wanting to deploy web applications and
XML web services by using Visual Studio.NET will
be at ease by the inclusion of new Web Hosting tab
on the Start page in Visual Studio.NET. The Web
Hosting tab gives developers access to a list of
ASP.NET Web hosters to provide free Web space
and are integrated with Visual Studio.NET to
facilitate the deployment of completed applications
through a wizard.
Main Menu 34 of 63
Introduction to Visual Basic .NET
Third-party downloads
Hundreds of software component vendors, training
companies and other partners have already adopted
and created .NET based software that is available for
developers to extend their solutions with Visual
Studio.NET. These third party resources can easily
be found on the “What‟s New” tab on the Start page
in Visual Studio.NET.
It provides a place for developers to learn about the
new features in Visual Studio.NET as well as a place
to learn about the third party vendors
Main Menu 35 of 63
Introduction to Visual Basic .NET
Shared Event Logs
Writing Application errors to shared event log
Event logs supply the user interface for viewing the
logs and a programming interface for examining the
logs. Event logging, thus, provides a standard
centralized way for Windows and applications to
record important software and hardware events.
Main Menu 36 of 63
Introduction to Visual Basic .NET
Visual Basic. NET
In 1991, Visual Basic came as a fast, powerful and
easy-to-use front-end tool used for developing
simple user interfaces. Since then, Visual Basic has
gone through many up-gradations. Visual Basic 3
added a simple way to control the most powerful
databases available. Visual Basic 4 added support
for 32-bit development and also began the process of
turning Visual Basic into a fully object oriented
programming language. Visual Basic 5 added the
ability to create true executables and even the ability
to make custom controls.
Main Menu 37 of 63
Introduction to Visual Basic .NET
Visual Basic. NET
To enable Visual Basic developers to benefit from
object-oriented design and to simplify the
development of enterprise Web applications, full
object-oriented language features, including
implementation inheritance, are supported in the
next version of Visual Basic - Visual Basic .NET.
The main task of a .NET environment is to create a
common platform for building applications that can
be considered as reusable, interoperable services
over the Internet and intranet.
Main Menu 38 of 63
Introduction to Visual Basic .NET
Visual Basic. NET
This allows developers to write their applications in
any programming language and to access any
component easily, regardless of what programming
language it was developed in. For example, a VB
application can call a method in a component written
in C++ and can catch events from an application
written in COBOL.
VB.NET enables the user to develop a scalable code
for web applications and windows applications using
a Visual Studio.NET environment.
Main Menu 39 of 63
Introduction to Visual Basic .NET
Features of Visual Basic .NET
Visual Basic .NET provides a first class object-
oriented programming language with the features
such as inheritance, overloading, and parameterized
constructors. Additionally, developers will be able to
create highly scalable code with explicit free
threading and highly maintainable code with the
addition of modernized language constructs like
structured exception handling.
VB.NET provides all the language characteristics
that developers need to create robust, scalable,
distributed Web applications with the following
features: Main Menu 40 of 63
Introduction to Visual Basic .NET
Features of Visual Basic .NET
Object Oriented Programming Features
Earlier versions of Visual Basic were not fully object-
oriented in nature. VB.NET now supports almost all the
object-oriented features. To understand these features,
first see the advantages of the Object Oriented
Programming.
There are several weaknesses with traditional structured
programming where data is stored separately from
procedural code. Any code that is written as structured
code is not modular. Because data elements are
accessible from any code, it is possible for data to be
modified without the developer's knowledge.
Main Menu 41 of 63
Introduction to Visual Basic .NET
Features of Visual Basic .NET
This can result in runtime errors that are very difficult to
debug. Additionally, maintenance can become a
substantial task. Trying to understand the global impact
of changing a single line of code with structured
programming can be very difficult. Finally, this reliance
on the programmer to manage both code and data results
in much lower rates of reuse.
Object oriented approach packages data as well as the
methods/procedures that act upon that data into a single
unit called an object. Let‟s see how Object-oriented
Programming (OOP) solves these problems.
Main Menu 42 of 63
Introduction to Visual Basic .NET
Features of Visual Basic .NET
Data hiding
The data can be insulated from direct access by the
program. This is called as data hiding. This prevents
unauthorized modification of the code.
Inheritance
It is the process by which objects of one class acquire
the properties of objects of another class. By inheriting
from predefined objects, developers can more rapidly
construct complex applications. Since writing new code
always has the potential for incorporating bugs, reusing
tested code minimizes the chances of additional bugs.
Main Menu 43 of 63
Introduction to Visual Basic .NET
Features of Visual Basic .NET
Encapsulation
The wrapping up of data and methods into a single unit
(called class) is encapsulation.
Reusability
Concept of inheritance provides the idea of reusability.
OOP allows developers to reuse code and data together
through inheritance.
Polymorphism
It allows objects having different internal structures to
share the same external interface.
Main Menu 44 of 63
Introduction to Visual Basic .NET
Features of Visual Basic .NET
Overloading
It gives developers the ability to create different versions
of a Sub or Function that have the same name, but
different argument types.
Parameterized constructors
It allows you to create a new instance of a class while
simultaneously passing arguments to the new instance.
Constructors are essential for object-oriented
programming since they allow user-defined construction
code to be passed parameters by the creator of the
instance.
Main Menu 45 of 63
Introduction to Visual Basic .NET
Exception Handling
Exception is an error occurred due to any abnormal
behavior of the code. Developers need to trap these
errors and send the control of the code to another
part of the program accordingly.
With VB.NET, exception handling has become more
structured. Developers can nest their exception
handling, and there is a control structure for writing
cleanup code that executes in both normal and
exception conditions.
Main Menu 46 of 63
Introduction to Visual Basic .NET
Strict type checking
It generates compile-time errors for any data type
conversions that may cause an error at runtime.
Option Strict improves type safety by generating
errors when a conversion is required which could
fail at runtime or which is unexpected by the user,
like the automatic conversion between numeric
types and strings.
Main Menu 47 of 63
Introduction to Visual Basic .NET
Shared members
Shared members are data and function members of
classes that are shared by all instances of the class.
Sharing a single instance of a data member or
function among all instances of a class is required in
a Visual Basic application with inheritance.
Main Menu 48 of 63
Introduction to Visual Basic .NET
IDE of Visual Basic .NET
This section deals with the user interface in Visual
Basic. NET environment and its components.
Main Menu 49 of 63
Introduction to Visual Basic .NET
IDE of Visual Basic .NET
See the figure given below of
„Start Page‟. There are 2
hyperlinks provided, which
are
Open Project: - This link
opens a project, which has
been developed earlier.
Project is a set of files that
make up an application under
construction.
New Project: - This link
allows user to start with a new
project in desired
programming language.
Main Menu 50 of 63
Introduction to Visual Basic .NET
IDE of Visual Basic .NET
The window also shows the
hyperlinks with file names
of recent projects
developed and their last
modification date. User can
directly open the required
project using these links.
What‟s New
This link provides the
information about
enhancement in Microsoft
technologies.
Main Menu 51 of 63
Introduction to Visual Basic .NET
IDE of Visual Basic .NET
Online Community
This link allow user to
access Microsoft
Newsgroup.
Headlines
This links gives the latest
MSDN news as shown
below
Main Menu 52 of 63
Introduction to Visual Basic .NET
IDE of Visual Basic .NET
Search Online
Using this link user can search for the topic for which he
need to access MSDN help.
Downloads
This page provides links to product updates, sample code,
and SDK releases available for download from the internet.
XML Web Services
This link enables us to search for registered XML Web
Services to include it in our applications. This link also
enables us to publish a user‟s created XML Web Services to
the community
Main Menu 53 of 63
Introduction to Visual Basic .NET
IDE of Visual Basic .NET
Web Hosting
This link quickly post Web
applications and Web
services created in Visual
Studio directly to the
Internet.
My Profile
This link allows us to
personalize the settings of
the GUI by selecting
appropriate option of the
combo box.
Main Menu 54 of 63
Introduction to Visual Basic .NET
Solution Explorer
Solution Explorer window provide an organized view of the
project and their files. To access Solution Explorer select
Solution Explorer on the View menu
A solution logically contains the projects in different
languages and files needed to build a Visual Studio
application. Solution Explorer helps us to view the different
projects contained in a solution.
A solution can contain multiple projects that can be open,
close, and save together. Each project in a solution might
contain multiple files or items. The types of items contained
within a project vary according to the development language
used to create them.
Main Menu 55 of 63
Introduction to Visual Basic .NET
Server Explorer
Server Explorer is the
server management console
for Visual Studio .NET. It
is used to open database
connection and log on to
the servers and explores the
databases and system
services. To access server
explorer select Server
Explorer on the view menu.
Main Menu 56 of 63
Introduction to Visual Basic .NET
Server Explorer
Using Server Explorer one can do the following
things:
Connect to servers and view their resources
Make data connections to SQL Server or other types
of databases.
Configure and integrate Exchange 2000 Servers into
your application.
Find out information about processes, services, and
DLLs loaded on a server.
Main Menu 57 of 63
Introduction to Visual Basic .NET
Properties Window
Property window is used to
view and change the design
time properties and events
of selected objects that are
located in editors and
designers. This window can
also be use to edit and view
the file, project and solution
properties. Properties
Window can be access by
selecting Properties
Window on the View
menu.
Main Menu 58 of 63
Introduction to Visual Basic .NET
Toolbox
The toolbox displays a
variety of item for use in
Visual Studio .NET
projects. The tabs and items
available from the toolbox
change, depending upon the
designer or editor currently
in use. Toolbox can be
accessed by selecting
Toolbox on View menu.
Main Menu 59 of 63
Introduction to Visual Basic .NET
Summary
Key points covered in this chapter are:
Visual Studio.NET (VS.NET) is a powerful
development tool and provides an IDE for various
different languages.
Visual Studio .NET makes the development process
substantially easier and more productive by
providing a drag-and-drop rapid application
development solution for developers
Server Explorer (as shown below) is the server
management console for Visual Studio .NET.
Main Menu 60 of 63
Introduction to Visual Basic .NET
Summary
While Visual Studio.NET will install on all 2000,
NT, Me, 98, Windows 2000 is required to use all the
features of the .NET framework. Some features such
as GDI+ are only supported in Windows 2000.
For working with databases, VS.NET includes
comprehensive features. From within the VS.NET,
databases and schemas, indexes, triggers and other
items can be created.
Main Menu 61 of 63
Introduction to Visual Basic .NET
Self Assessment
Fill in the blanks:
Server Explorer of Visual Studio.NET shows an entire
_________________
computer including databases, message queues,
performance counter services, processes, event logs and all
other installed server elements
Wrapping up of data and methods into a single unit is called
Encapsulation
______________
Server Explorer can also be used to perform
The ________________
administrative tasks on Microsoft Windows services like
starting, stopping and pausing services.
Visual Studio.NET supports a SharedIDE
_____________environment
for all languages within it.
Main Menu 62 of 63
Introduction to Visual Basic .NET
Self Assessment
State True or False:
Event logs supply the user interface for viewing the
logs and a programming interface for examining
the logs True
The data cannot be insulated from direct access by
the program False
A solution can contain multiple projects that can be
open, close, and save together True
Main Menu 63 of 63