Вы находитесь на странице: 1из 18

UNIT 1 - An Introduction to Visual Basic.

NET and Program Design

Q.1- What are the different application types in Visual Basic and Windows Programming?
Explain all in detail.

The visual basic programming environment allows creating programs for windows operating
system as well as web. The following are the different types of application that can be
developed using visual basic.net.
1.Windows Applications
2.Web Application
3.Console Application
4.Web Services
5.Windows Service

1.Windows Application
• A windows application is a program with a graphical user interface that runs in a
windows environment.
• It is considered as a stand-alone application which means that it does not require other
applications or data sources to run in the operating system.
• Visual basic.Net allows developers to create windows application with a graphical user
• The windows graphical user interface serves with menus, buttons and other graphical
icons which makes the work of the user becomes very easy with respect to enter the
data and instructions into the computer.

2. Web Application
• A web application is an application utilizing web and [web] browser technologies to
accomplish one or more tasks over a network, typically through a [web] browser.
• Visual basic.Net can be used to create web sites and pages that run in almost any web
browser on any operating system.
• It provides a graphical user interface for the web applications so that user can interact
with the application.
• When a web page is created using VB.NET and program code is compiled into HTML
{Hypertext Markup Language}.
• HTML is the web authoring Language that uses a set of special instructions called tags or
markups to define the structure and layout of a web document and specify how the
page is displayed in a browser. The resulting application is called a Web application.

3. Console Application
• These are light weight programs run inside the command prompt (DOS) window. They
are commonly used for test applications.
• Visual Basic.Net can be used to create console applications that run within the windows
command prompt environment.
• While working with a command prompt interface, a user enters data instructions into a
computer by typing keywords or pressing keys on the keyboards.

4. Web Services
• Web services are “web callable” functionality available via standards like HTTP, XML &
• A web service is program that provides information to another program over the web,
but does not have the user interface. The information provided usually is specific and
well defined.
• A user does not provide data directly to web service, rather, data is sent in an electronic
format from the web application to the web service and back again over the internet.
• For example, an airline may create a web service for programmers not associated with
the airline may develop travel-related web applications. The airline’s web service may
accept the input and back as output to the web application.
• Once the web application receives data from the airlines web service, the data can be
formatted for display on a web page or used in any other way required by the

5. Windows Services
• A service is a program that runs in an operating system and performs such tasks as
maintenance, information gathering, security, and notification but requires no user
• Windows services are long-running executable applications that run on the system as a
background process. These applications do not interfere with the working of the other
processes that run on the same computer.
• Windows services execute within separate windows sessions creates specifically for
each window service.
• These services do not have a graphic user interface and are ideal for running on the
server. Windows services were earlier called NT services.
• Visual Basic.Net allows you to create windows services.

6. Components
• They serve as a helper to another program.
• Software components are (binary) units of independent production, acquisition, and
deployment that interact to form a functioning system.
• A software component is a unit of composition with contractually specifies interface and
explicit context dependencies only.
• Components are black boxes.
• Application developer that makes use of components need not understand the
implementation of those components.
• They are reusable code in its simplest form.
• Visual Basic.Net can create components for other programs to use. A component
functions as a prebuilt program that can be used by other programs or applications to
complete a task or process.

Q.2- What is .NET?

The .NET encompasses a series of technologies that allows almost any type of application to run
in a common environment.
The common environment in which applications created for .NET run is called
.NET framework.

Q.3- Explain VB.NET IDE.

• Understanding the main window

• Tabs at the top of the screen space identify open windows.
• Initial choices include the Start page, the Code window, the Designer window, and the
current Help screen.

• Understanding toolbars
• Toolbars provide a one-click shortcut to menu selections.
• Standard toolbar always visible.

• Understanding Menu bar

• The menu bar of the VB.NET screen displays the commands you use to work with
VB.NET some of the menus, like File, Edit, View, and Window, are common to most
windows applications.
• Others, such as Project, Build, and Debug, provide commands specific to programming
in VB.NET.

• Understanding the Status bar

• The status bas is located at the bottom of the window.
• It displays the current state of the IDE.
• It consists of mode indicators and status indicators.

• Understanding the Class View

• Class view enables you to examine all the symbols used in your application, or available
to your application.

• Understanding the Properties window

• Read only properties are disabled.
• Expansion button appears to the left of group-level properties.
• Complex properties can be set by clicking an ellipse.
• When you can select from a list of property setting choices, the Settings box is a combo
box with a down arrow that lists the choices.
• Property window has its own toolbar.

• Understanding the Output window

• Output window displays messages to you from the IDE.

• Understanding the Toolbox

• Toolbox is subdivided by tabs, and the particular tabs available depend on the contents
of the main window.
• Data tab
• Components tab
• Windows Forms tab

• Understanding Server Explorer

• Server explorer opens and manages data connections to both internal and external
databases and related services.

Q.4- Explain VB.NET framework in detail.

The .NET Framework is a service or platform for building, deploying and running application.
The .NET Framework consists of:
Common Language Runtime (CLR)
• It is the execution engine for .NET Framework applications.
• It is the heart or backbone of the .NET.
• It is the run time engine provided by the .NET Framework.
• It provides an infrastructure for running programs and allows them to communicate
with other parts of the .NET Framework.
• It provides a number of services, including the following:
Code loading and execution.
Application memory isolation.
Verification of type safety.
Conversion of IL to native code.
Access to metadata.
Managing memory for managed objects.
Enforcement of code access security.
Exception handling, including cross-language exceptions.
Common Type System (CTS)
• CTS allow programs written in different programming languages to easily share
• A class written in C# should be equivalent to a class written in VB.NET.
• Languages must agree on the meanings of these concepts before they can integrate
with one another.
• Common Language Specification (CLS) forms a subset of CTS. This implies that all the
rules that apply to CTS, apply to CLS also.
• It defines rules that a programming language must follow to ensure that objects written
in different programming languages can interact with each other.
• CTS provide cross language integration.
• The common type system supports two general categories of types:
• Value types
• Reference types

• Value types:

• Store directly data on stack. In built data type.

• Example: dim a as integer

• Reference types:

• Store a reference to the value’s memory address, and are allocated on the heap.
• Example: Dim obj as new Oledbconnection

Common Language Specification (CLS)

• CLS includes basic language features needed by almost all the specifications.
• It serves as a guide for library writers and compiler writers.
• The Common Language Specification is a subset of the common type system.
• The CLS is also important to application developers who are writing code that will be
used by other developers.

• An assembly is the primary building block of .NET Framework application.
• An assembly is a logical DLL (Dynamic Link Library).
• It consists of DLLs or executables.
• It is a collection of functionality that is built, versioned, and deployed as a single
implementation unit (as one or more files).
• There are two types of Assemblies:
Private Assembly
Shared Assembly
• Private Assembly
• It is used only by a single application, and is stored in that application’s install directory.
• A private assembly name need only be unique within the application that uses it.
• Shared Assembly
It is one that can be referenced by more than one application.
In order to share an assembly, the assembly must be explicitly built for this purpose by giving it
a cryptographically strong name.(referred to as a strong name)
• Metadata stored within the assembly.
• .NET records information about compiled classes as Metadata.
• Metadata means data about data.
• A .NET language compiler will generate the metadata and store this in the assembly.
• On the .NET Platform programs are compiled into .NET PE (Portable Executable) files.
• The header section of every .NET PE file contains a special new section for Metadata.
• Metadata is nothing but a description of every namespace, class, method, property etc.
contained within the PE file.
• The CLR uses this Metadata to:
Locate classes.
Load classes
Generate native code
Provide security

.NET Framework Class Library (FCL)

• In C, <conio.h>, <stdio.h> etc. are header files. Header files are also added program to
use inbuilt functions.
• The .NET Framework is collection of classes or namespaces that can be used to develop
• The class library consists of data classes, XML classes, Web forms classes, Windows
forms classes, Smart device classes, Input Output classes, etc.
• Other name of FCL is BCL-Base Class Library.

• .NET Framework class library is a collection of namespaces.
• Namespace is a logical naming scheme for types that have related functionality.
• Namespaces means nothing but a logical container or partition.
• The notion of the namespace plays a fundamental role in the .NET Framework.
Garbage Collection (GC)
• Garbage collection is a mechanism that allows the computer to detect when an object
can no longer be accessed.
• It automatically free up the memory used by that object.
• One of the advantages of CLR is automatic memory management that uses the garbage
collection mechanism.
• The CLR’s garbage collector GC manages the allocation and release of memory for an
• We don’t have to write code to perform memory management tasks when you
developed managed applications.

• Step 1:Select a Compiler

For VB.NET select VBC, for C# selects CSC same for all language wise select a compiler.
VBC stands for Visual Basic Compiler.
• Step 2: is compile Code to Microsoft Intermediate Language (MSIL)

Converting your source code into MSIL and generates the metadata.
• Step 3: Compiling MSIL to native code
JIT compiler translates the MSIL into native code.
• Step 4 (Final step): Running code
The CLR provides the environment that enables execution to take place and provide other

Microsoft Intermediate Language (MSIL)

• MSIL is the CPU- independent instruction set into which .NET Framework programs are
• It contains instructions for loading, storing, initializing, and calling methods or objects.
• Combined with the metadata and the common type system, MSIL allows for true cross-
language integration.
• MSIL also known as CIL- Common Intermediate Language, or IL- Intermediate
Just-in-Time (JIT)
• It’s a smart compiler and stands for “just-in-time”.
• JIT does not compile whole program each time and every time. It compiles only that
portion of the program in which functions are called during that time if native code is
already present then that data will not again compiled. If changes are made then it is
possible that it will generate MSIL to Native.
• There are 3 types of JIT:
• Pre-JIT: It compiles complete program into native code in a single compilation cycle. This
process is done at the time of deployment of the program.
• Econo-JIT: It compiles only those methods that are called at runtime.
• Normal-JIT: It’s like Econo-JIT. The methods are compiled the 1st time they are stored in
cache. When the same methods are called again the compiled code from the cache is
used for execution.

• An assembly is the basic building block of .NET application.
• The AssemblyInfo.VB file contains information about the assembly, its version number,
dependencies, product, copyright, trademark, description, etc.
• General information about an assembly is controlled through the following set of
<Assembly: AssemblyTitle(“”)>
<Assembly: AssemblyDescription(“”)>
<Assembly: AssemblyCompany(“”)>
<Assembly: AssemblyProduct(“”)>
<Assembly: AssemblyCopyright(“”)>
<Assembly: AssemblyTrademark(“”)>

• It’s one kind of software. It is used to view basic information about the project.
• ILDASM.exe can opens any .NET Framework .exe or .dll assembly.
• It displays the MSIL code, namespaces, methods, events, fields, interfaces, etc.
ILDASM.exe is used to examine native .NET Framework assembly.
Q.5- Explain Data types.

• The data type of a programming element refers to what kind of data it can hold and how
that data is stored.
• There are mainly four categories of it:
Numeric data types (short, integer, long, single, double, decimal)
Character data types (char, string)
Miscellaneous data types (Boolean, byte, date, object)
User-defined Data types(Structure, Array, Enum)
• Numeric Data types
It occupies 2 bytes.
The range of it (-32,768) to 32,767.
Prefix we can use is ‘sht’ and store only whole numbers.
Example- Dim shtRollNo as short
• Integer
It occupies 4 bytes.
The range of it (-2,147,483,648) to 2,147,483,647.
Prefix we can use ‘int’ and store only whole number.
Example- Dim intRollNo as Integer
• Long
It occupies 8 bytes.
The range of it (-9,223,372,036,854,775,808) to 9,223,372,036,854,775,807.
Prefix we can use ‘lng’ and store only whole number.
Example- Dim lngBankIncome as Long
• Single
It occupies 4 bytes.
The range of it (-3.4028235E+38) to (-1.401298E-45) for negative values ; 1.401298E-45 to
3.4028235E+38 for positive values.
Prefix we can use ‘sng’ and can store whole and fractional both.
Example- Dim sngSal as Single
sngSal = 50000.5555
• Double
It occupies 8 bytes.
The range of it (-1.7976931348623157E+308) to (-4.94065645841246544E-324) for negative
values ; 4.94065645841246544E-324 to 1.7976931348623157E+308 for positive values.
Prefix we can use ‘dbl’ and store whole and fractional both.
Example- Dim dblSatyamFraud as Double
dblSatyamFraud = 2222222222.564849
• Decimal
It occupies 16 bytes.
The range of it 0 to +/-79,228,162,514,264,337,593,543,950,335 with no decimal point ; 0 to +/-
7.922816251426433759343950335 with 28 places to the right of the decimal ; smallest non-
zero number is +/- 0.0000000000000000000000000001 (+/-1E-28).
Prefix we can use ‘dec’ and store whole and fractional both.
Example- Dim decIncome As Decimal
decIncome = 1.524846541654564E+19

• Character Data types

It occupies 2 bytes.
The range of it 0 to 65535.
Prefix we can use ‘ch’ and we need to write (“”).
Example- Dim chGen As Char
chGen = “M”
• String
It occupies 2 bytes.
The range of it 0 to approximately 2 billion Unicode characters.
Prefix we can use ‘str’ and we need to write (“”).
Example- Dim strAdd As String
strAdd=”P-R/12, Sola Bhagwat, A’bad”
• Miscellaneous Data types
• Boolean
It occupies 2 bytes.
The range is either “True” or ”False”.
Prefix we can use ‘bln’.
Example- Dim blnGen As Boolean
blnGen = True
• Byte
It occupies 1 byte.
The range of it 0 to 255.
Prefix we can use ‘byt’.
Usually byte data type is used to access the binary files, image, sound etc.
Example- Dim bytNo As Byte
bytNo = 223
• Date
It occupies 8 bytes.
Minimum value is 0:00:00 on January 1, 0001 and maximum value is 11:59:59 on December
Prefix we can use ‘dt’ and we need to write (# #).
The format of date variable is #mm/dd/yyyy#.
Example- Dim dtDob As Date
dtDob = #12/07/1997#
• Object
It occupies 4 bytes.
It can store any kind of data. Prefix we can use ‘obj’.
Example –Dim objTemp As object
objTemp = 5
• Use object at compile time when you do not know what data type the variable may
point to.
Whatever data type it refers to, an object variable does not contain the data value itself, but
rather a pointer to the value.

Q.6- Explain Form and Textbox along with properties and methods.

• A form is a representation of any window displayed in your application.
• The form class can be used to create standard, tool, borderless, ands floating windows.
• You can also use the form class to create modal windows such as a dialog box.
• A special kind of form, the multiple-document interface (MDI) form, can contain other
forms called MDI child forms.



Any colour selected
Sets the background colour of
Appearance Back color from
application window.
dialog box
Sets default colour for Any colour selected
Fore color controls that are added to from
the form. Dialog box.
Dictates appearance of form FixedSingle
Border; whether the form is Fixed3D
Form border
Sizable; and Maximize FixedDialog
buttons, Control menu box, Sizable
& Help behave. FixedToolWindow
Sets title to display on title bar
Text Any value
of the application window.
Sets form to be usable during True
Behavior Enabled
run time. False
Layout WindowState Dictates how a window
Should display initially during Maximized
run time.
Determines if a windows
Window True
ControlBox Control box should display on
Style False
the form.
Determines the icon that
Any icon selected
displays on the top-left corner
Icon from a file via a
of the window titlebar and on
dialog box.
the taskbar at run time.

• Text box controls allow entering text on a form at runtime.
• By default, it takes a single line of text, however, you can make it accept multiple texts
and even add scroll bars to it.
• We can prohibit user from entering text values into the text box during runtime by
setting its ReadOnly property.
• The properties can be set statically as well as dynamically.
• To set the properties statically property window can be used while dynamic setting of
the properties can be done through coding.

• The methods of the textbox control are listed as under:

Methods Description
Cut Moves the current selection in the text box to the clipboard.
Copy Copies the current selection in the text box to the clipboard.
Replaces the current selection in the text box with the contents of the
Clear Clears all text from the text box control.
Focus Sets the focus on the control.
Select Method to selects the text in the text box.
Select all Method used to select all the text in the control.
Show Display the text of the text box control.

• The properties of the Textbox control is listed as under:

Properties Description
Name Uniquely identifies the textbox control.
Border style Gets or sets the border style for the control.
Text Gets or sets the text associated with this control.
Text align Gets or sets the alignment of text in the textbox.
Gets or sets a value specifying if the control should be automatically
Auto size
resized to Display all its contents.
Max length Gets or sets the maximum length of the text.
By default textbox accept single line of Characters, if you need to
Multiline enter more than one line in a text box control, you should change the
multiline property is to true.
Prohibits user from entering value into the control. By default the
Read only background
color of the control becomes grey in color.
Indicates whether a multiline text box control automatically wraps to
Word wrap the
beginning of the next line when necessary.
Location: X Indicates the distances from the left border of the form in pixels.
Location: Y Indicates the distance from the top border of the form in pixels.
Height Gets or sets the preferred height of the control in pixels.
Width Gets or sets the preferred width of the control in pixels.
Gets or sets a value indicating whether the user can tab to the
Tab stop

7) Write a note on Numeric UpDown control with its properties.

A NumericUpDown control allows user to provide a spin (up / down) interface to move through
pre-defined numbers using up and down arrows.

A NumericUpDown control contains a single numeric value that can be incremented or

decremented by clicking the up or down buttons of the control. The user can also enter in a
value, unless the ReadOnly property is set to true.

The numeric display can be formatted by setting the DecimalPlaces, Hexadecimal, or

ThousandsSeperate properties. To display hexadecimal values in the control, set the
Hexadecimal property to true. To display a thousandsseperateor in decimal numbers when
appropriate, set the thousandsSeperate property to true.

To specify the number of digits displayed after the decimal symbol, set the DecimalPlaces
property to the number of decimal places to display.

To specify the allowable range of values for the control, set the Minimum and Maximum
properties. Set the incremented value to specify the value to be incremented or decremented
to the Value property when the user clicks the up or down arrow buttons.

The properties of the numericupdown control is listed as under:

Property Description
Name Uniquely identifies the numericupdown control.
BorderStyle Gets or sets the border style for the control.
Text align Gets or sets the alignment of the text in the numericupdown control.
Up down
Gets or sets the alignment of the Up/Down button.
Value The Value property represents the currently selected values in a control.
Interceptarr- Gets or sets a value indicating whether the user can use the UP ARROW keys to
owkeys increment / decrement values.
Decimal We can formate the number of a NumbericDropDown control using the
places DecimalPlaces property.
Increment property is used to set the value that is increased or decreased when up
and down button are clicked.
Maximum Maximum property is used to set the maximum value of NumericUpDown control.
Minimum Minimum property is used to set the minimum value of NumericUpDown control.
Thousands Gets or sets a value indicating whether a thousands separator is displayed in the
Separator spin box when appropriate.
Location:X Indicates the distance from the left border of the form in pixels.
Location:Y Indicates the distance from the top border of the form in pixels.
Height Gets or sets the preferred height of the control in pixels.
Width Gets the preferred width of the control in pixels.

8) Write a short note on Managed Execution process.

Managed execution process is a process where CLR executes the managed code. The steps
involved in this process are:
a) Choosing the right compiler
b) Compiling the code to MSIL. This also generates the required metadata.
c) Compile the MSIL ode to native machine code.
d) Executing the code with the variety of services available.

The Common Language Runtime (CLR) is an Execution Environment.

Common Language Runtime (CLR)’s main tasks are to convert the .NET Managed Code to native
code and also controls the interaction with the Operating System. In the .NET framework, an
intermediate .NET system, known as the Common Language Runtime (CLR), takes control of
the application and runs the application under the operation system. The CLR is the
environment that executed Visual Basic .NET programs.

When you create .NET application however, the resulting applications consists of language that
the CLR understands, called the Microsoft Intermediate Language (MSIL). The MSIL is
sometimes refers to as IL.
In addition to reading the MSIL, the CLR appropriates many tasks that typically have been
performed by the operating system.

Visual Basic.NET Windows’s applications still are considered stand-alone applications, even
though they require the CLR to operate.

Visual Complies Microsoft Runs on Command Runs on Windows

Basic .Net Intermediate Language Operating
Program to language Runtime System.

9)Explain button control with its properties.

A Button is a control, which is an interactive component that enables users to communicate

with an application which we click and release to perform some actions.

We can load image on button.

By default, the button has Click event.

The properties of the Button control is listed as under:

Properties Description
Name Uniquely identifies the button control.
Flag style Gets or sets the flat style appearance of the button control.
Visible Property used to make the control visible or invisible
Enabled This property is used to enable the control.
Width This property is used to specify the width of the control.
Font Property used to set the font properties like bold, Italic, Name and so on.
Height Property used to specify the height.
Width Property is used to set the width of the control.
Left Property is set the X coordinate of the control.
BackColor Property is used set the background color of the control.
Image Gets or sets the image that is displayed on a button control.
Property is used to set or get the value returned to the parent from when the
button is clicked.
Image Align Property is used to get or set alignment of the image.
Text Align Gets or sets the alignment of text in the button.
ImageList Property is used to set or get the Image List that contains the images displayed.
10) Define Namespace with example.

Namespace organize the objects defined in an assembly.

Assembly can contain multiple namespaces, which can in turn contain other namespace.

Namespaces prevents ambiguity and simplify references when using large groups of object such
as class libraries.

For example, the .NET Framework defines the Listbox class in the System.Windows.Forms

‘Namespace VBNetLib
Public class MyUsefulClass
Public Shared Sub DoesSomethingGood()

End Sub
End Class
End Namespace

11) List out common properties of control.

Property Description
BackColor Specifies the background color of the control.
BorderStyle Generally, specifies whether or not a control has a border.
Text The string of text that is to be displayed in the control.
Enabled Determines whether or not the control can respond to user-generated events.
For controls displaying text, specifies the font (name, style, size, etc.) to be
applied to the displayed text.
ForeColor Specifies the color of text or graphics to be displayed in the control.
Defines which mouse pointer (cursor) displays when user moves the mouse over
the control.
Height Specifies the height of the control in pixels.
Specifies the distance (in pixels) between the internal left edge of a control and
the left edge of its container.
Ensures that a control cannot be moved during design time; prevents
inadvertently moving the control once it is positioned.
Name The string value used to refer to the control in code.
Size Indicates height and width of the control in pixels.
Image Specifies the graphic to be displayed in the control.
Location Indicate distance from the top and left border of the form in pixels.
TabIndex Specifies the tab order of a control within its parent form,
TabStop Specifies whether or not the user can use the Tab key to give focus to the control.
Tag A string containing extra data associated with the control.
Specifies the distance (in pixels) between the internal top edge of a control and
Top the
top edge of its container.
Visible Specifies whether the control is visible or hidden.
Width Specifies the width of the control in pixels.

12) Explain Label with its properties.

The Label control represents a standard Windows Label.

There will be no application created without using Label.

It is generally used to display some informative text on the GUI which is not changed during

The user cannot interact with this control and give input during runtime.

We can set any Image on this control.

The properties of the Label control is listed as under:

Property Description
Name Uniquely identifies the label control.
Autosize Gets or sets a value specifying if the control should be
automatically resized to display all its contents.
BorderStyle Gets or sets the border style for the control.
FlatStyle Gets or sets the flat style appearance of the Label control
Font Gets or sets the font of the text displayed by the control.
FontHeight Gets or sets the height of the font of the control.
ForeColor Gets or sets the foreground color of the control.
Image You can load Image in Label control by setting this property.
Image Align The alignment of the image selected in the image property is
possible from this property.
Location: X Indicates the distance from the left border of the form in
Location: Y Indicates the distance from the top border of the form in
PreferredHeight Gets the preferred height of the control.
PreferredWidth Gets the preferred width of the control.
TabStop Gets or sets a value indicating whether the user can tab to
the Label. This property is not used by this class.
Text Gets or sets the text associated with this control.
TextAlign Gets or sets the alignment of text in the label.