Overview of Visual Studio .NET Page : 1.
then VS.NET is installed. Visual Studio 2015 was introduced by Microsoft in 2015. It
supports Programming languages such as VB.NET, C#, VC++, F#, JavaScript, Python
etc. Microsoft has added many new features for building mobile applications.
(1) Visual Studio Express: Express edition is free for everyone. But it proides
limited features which are capable of fulfiling only the basic needs of software
build up. Express editions started with Visual Studio 2005.
(ii) Visual Studio Professional: Professional edition of Visual studio is for
development by individuals. This edition is reasonable in price too.
(ii) Visual Studio Premium: Premium edition is used by people who make high
quality usage of the IDE. It includes advance tools for planning, developing,
testing, code analysis and debugging for development teams.
(iv) Visual Studio Ultimate: This is the ultimate edition of the product with all the
components that could exist within Visual Studio. This edition provides
advanced debugging capabilities with all architecture and modeling tools.
1.5 INSTALLING AND STARTING VISUAL STUDIO
Many versions of Visual Studio are available in the market. The contents of this
book are based on Visual Studio 2015 Professional. The steps to install Visual Studio
2015 are described as given below. However, the steps to installVisual Studio 2022 are
given in Appendix A.
º Double click on the executable fle, vs_professional.exe. It starts installing
Visual Studio. It shows starting screen as shown in Figure 1.5.
Figure 1.5: Starting Screen
D Visual Studio
Professional 2015
Initializing setup
Configuring feed.
Overoiew of Visual Studio NE
Page : 1.10
'Instal'
installation (Default) and then click on
Select location and type ofconirmation, Click on Yes' button as shown in
button, It will prompt for
Figure 1.6.
Type
Location and Installation
Figure 1.6: Choosing
D Visual Studio
Professional2015
location
Choose your installotion 14.0
(B6)\Microsoft Visual Studio
CAProgram Files
GD across all drives,
Setup requires up to 9
installation
Choose the type of
Detault Desktop features
Includes C#/NBWeb and
Custorn
features for your installaticon
Allows youto custormize
after setup via
additional features at any time
Youcan add or remove Corntrol Panel.
Prograrns and Features in the
acknowledge that Iaccept the cesS
By clicking the "Install" button, I
Tecmsand Povaoy Sttenet,
Install
Cancel
During installatior
> It takes time to install. So, wait until next message comes.
the following screen will appear as shown in Figure 1.7.
Figure 1.7: Acquiring and Applying Visual Studio Resources
D Visual Studio
Professional 2015
Acquiring
Microsoft Visuat5tudio JavaScript Language Service
Applying
Visual Studio 2015 Prerequisites
Overview of Visual Studio .NET Page : 1.11|
After successful installation, the message Setup Completed' will appear. Click
on button Launch' as shown in Figure 1.8.
Figure 1.8: Completing Visual Studio Setup
Visual Studio
Professiornal 2015
Setup Completed.
However, not all features installed correctly,
Please correct the following problems to ensure ful product functionality.
To learnmore, youcanreview the list of commonisses ad workarounds
or examine the logfle.
Visual Studio 2015 Update 3
This product did not downlosd successfully: There are
Curtently no active network connections. Background
Intelligent Transfer Service (8ITS) will try again when an
adapter is connected.
RUpdate for Microsoft Visual Studio 2015 (083165756)
This product did not download successfully, There are
currently no active network connections Background
Intelligent Transfer Service (ers) wil try again when an
adapter is connected.
A JavaScnipt Language Service for Vsual Studio
This product did not download successtully. There are
currently no active network connections Background
Intelligent Transfer Service (BI19) wil try agin when an
ntrir phnartod
LAUNCH
First time when Visual Studio is launched, it prompts user to sign in to Visual
Studio. For signing, click on link - 'Sign in', otherwise click on the link - Not
now, may be later as shown in Figure 1.9.
Figure 1.9: Signing in
Visual Studio
Welcome. Sign in to Visual Studio.
Visual Studio will automatically keep you signed in, sync your
settings between devces, and connect to online developer seracez
Learn ore
Segn in
Not no, maype later
By signing in, you agree to the SsualStudio Online
Terma of Ue and Pmvacy Statennent
Page : 1.12 Overview of Visual Studio NE
>Wait for Visual Studio to start as it takes a few minutes as shown in Rio
1.10.
Figure 1.10: 'First use' Screen
DVisual Studio
We're preparina for first use
> Next, a start page of Visual Studio will appear as shown in Figure
1.11.
Figure 1.11: Start Page of Visual Studio
Quick Leanch (Ctr-Q
Start Page- Microsoft Visual Studio
Fle Edt Ve Rebug Team Tools Tegt Analyze Window Help
Sgn in
-
Attach.
Solution Erplorer
Start Page x
Discover what's new in Professional 2015
Visual Studio Learn abcut new features in Professional 2015
See whst's rewin the NET Framework
Explore what s new in Visual Studio Onl1ne
Start
New Projet Ready to Cloud-power your experience? New on Microsoft Platforms
Open Projec
Connect to Azure
Open from Source Control. Windows
Microsaft Azure
n ASP.NET S and Web
News n Mciesoft Office
Recent
S Share?oint Development
We are unable to download content due to network issues.
(Click to retry
Featured Videos
We are unable to download content due to network issues.
Click to retry
9Snipping Tool
Keep page open after project
load
/ Show page on startup
Solution Explorer TeanEplorer
Pesdy
1810
O Type here tosearch RA D ) ENG 01-09-201s
º Now an application can be developed using Visual Studio. The Start Page of ID
consists majorly of the following options.
(1) The New Project: This helps in creating new projects. Variou
11!
applications can be built using different programming languages
Visual Basic, Visual C#, Visual C++t, Visual F#, JavaScript, Python etc.
(ii) The Open Projects: This shows a list of recently created/used project
For opening an existing project, Click on Open Projects.
(iii) News: This section provides latest online news, announces new releast
and updates.
Overview of Visual Studio NET Page : 1.13
1,6 VISUAL STUDIO .NET IDE
Visual Studio Integrated Development Environment (IDE) is a set of software
development tools for building GUI and writing code for different types of applications
using minimal time and efforts. It provides Tool Box, Source Code Editor, Debugging,
Compilation, Program execution environment and many more options. When Visual
Studio IDE is started, click New Project option and a dialog box appears as shown 1n
solution
Figure 1.12. When IDE is opened first time or a new project is chosen, a new
is created by default.
Figure 1.12: Choosing New Project in Visual Studio
New Project
Search Installed Templates (Ctrle E)
Recent NET Framework 4.5.2 - Sort by Default
4Installed Visual Basic
Type: Visual Basic
Windows Forms Application a
Aproject for creating an application with
1 Templates Windows user interface
4Visual Basic WPF Application Visual Basic
t Windows
Web Console Application Vitual Basic
Cloud
Etensibilty Shared Projnct Visual Basic
LightSwitch
Office/ShrePoint Cless Libay Visual Easic
Silverlight
Vinual BasiC
Test Clau Lary (otati
WCF
Workflow
IypeScript
Other Languages
Other Project Types
Samples
Online
Cck here ts ge kne and fed iemlates
Name FistWindowAppl
Cancel
Follow the steps given below after Clicking on New Project option.
(i) Select Visual Basic from Templates (First Pane)
() Select Windows (First Pane)
(ii) Select Windows Forms Application (Middle Pane)
(iv) Type the name of project as FirstWindowApp (Bottom Pane)
(v) Click OK button.
After creating a new solution in previous step, Visual Basic.NET IDE appears as
shown in Figure 1.13. The Title bar indicates the name of solution specified in the
previous step. This screen displays Form window, Solution Explorer window and
Property window besides many other menus, tabs and windows. Developer can now
start designing of GUI to develop applications using Visual Studio .NET.
Operview of Visual
Page : 1.14 Studio. NET
in Visual Studio 2015
Figure 1.13: First Screen after creating a new Solution
Prdgetet
form1 stem Wndofoms Fo
RgpToeyot
Sholeon
ShodaTetoat
SaeGiotje Auto
Wndonncton
Startotion
Tog
Form1
Tet
ToplMot Fale
Text
The ted es0cetedwth the comtrol
OTvpe here to Search
windows. The main windows of IDE
The Visual Studio IDE includes various
are described as follows.
project, a Form is displayed in
(i) Form/Design Window: On creating a new
is also considered a
middle pane as shown in Figure 1.13. A Form The default
Title Bar.
control by itself. It has 'Form 1' written in its
System.Windows.Forms.Form
Form is an object and an instance of the
empty space,
class of System namespace. Click anywhere in the Form's Text, Size,
Name,
then Forml's property window shows its properties like
MaximizeBox,
Font, Location, Foreground color, background color,
MinimizeBox etc. These properties can be changed by typing a value or
Form is defined
selecting a value from a drop-down list. The title of the
Form1. To change the
by the Text property and its default value is
Form's title, click in the box on the right of the Text property and type
Form1' is also
text. Title always appears in the title bar of Form window.
used as the default name for the Form and it can be changed by
changing its Namne property. The current Form is represented by the
name Me' in coding. For example,
Me.Text="Sample Title of Form"
(ii) Toolbox: Toolbox acts as a palette. It contains many controls that can be
placed in Visual Studio forms for designing Graphical User Interface.
Controls are categorized further into ten different categories such as Al
Windows Forms, Common Controls, Containers, Menus & toolbars, Data,
Components, Printing, Dialogs and WPF Interoperability and General.
Overview of Visual Studio NET |Page : 1.15
Generally, Toolbox is shown on the left side of Visual Studio IDE. The
developer can drag a control from Toolbox and drop it on the already
open Form. To see the commonly used controls, click on AIl Windows
Forms'. The partial list of controls is shown in the left pane of
Figure 1.14.
Figure 1.14: List of Controls in 'AllWindows Forms' Group
WindowsApplication1 -Microsoft Visual Studio
File Edit View Project Build Debug Tean Iools Test Analyze Window Help
2--Debug -Any CPU - Start
Toolbox Form1.vb (Design) 4
Sources
Data
Search Toolbox
Al Windows Forns BForml
Pointer
BackgroundWorker
gBindingNavigator
BindingSource
Button
CheckBox
CheckedListBox
ColorDialog
ComboBox
ContextMenuStrip
F DataGrid View
DataSet
DateTimePicker
(iii) Properties Window: It displays all the properties and their current
settings related to the selected control. The properties window comprises
Object drop-down list, List of properties and the Bottom section.
> Object drop-down List: In the properties window, the item that
appears at the top part of the property window is the control currently
selected.
> List of Properties: It describes property name in left column and its
present state in right column. Every time a user selects a control
either from the Form or from Object drop-down list, its corresponding
properties are shown in the window. State of any property can be
changed either at design time or run time. Change the properties of
the Formn at run tme by writing the relevant code. For example, the
property of the object can be defined by writing the object's name
followed by a dot and property name.
Me.Text="Sample Title of Form"
Me.MaximizeBox=False
Me.MinimizeBox=False
> The Bottom Section: It shows a description of the selected property.
(iv) Solution Explorer: Solution Explorer provides an organized view of
solutions, projects and files. It is a placeholder for one or more related
projects and their build or configuration settings. A project is always
ge : 1.16 Overview of Visual
Studio NET
included within a solution, When a new project is created, Visual
creates a solution by default, name as WindowsApplication 1' and
other name,
Studis
until the user changes the default nane to sorne
name is also shown in the title bar of Visual StudioIDE
By default,
differ
Solnarutimones
of solution and project are same which can be changed anda given Visual Stwa
names. Each project holds the code and data related to
solution,
application. More than one project can be created under a
Visual Studio uses two file types .sln and .suo for storing settings relates
solution. It has .
to solutions. A text file having extension .sln describes a
Another f
unique format and it is edited by the system automatically.
binary file.
with extension .suo stands for Solution User Options. It is a
during the las
stores user-level customized settings like list of files opened
It is a hidden file and
usage of solution or the location of breakpoints etc.
option is enabled for Windo
can be seen only if 'show hidden files'
explorer. A project is saved with extension .vbproj.
the View menu.
To access Solution Explorer, select Solution Explorer on
looks like as shown in Figure 1.15.
Figure 1.15: Solution Explorer
Solution Explorer
Search Solution Explorer (Ctrl+;)
VE WindowsAppication1
AMy Project
m- References
App.config
Ea Form1.vb
available databas
(v) Data Source: Data Source is used to show the
connections. (Database connections as covered later in this book).
edit cod
(vi) Code Window: The Code Window is used to write, display and
related to a Form. The code window appears either by double-clicking or
th
any part of the form or selecting View code' by right clicking on
Form. Alternatively, function key F7 can be used to bring the cod
definition window and press 'Shift + F7 to get design window of Form. B
default, the Code window shows the structure of a class Form1', defau
with 'En
name of Form. A class starts with 'Public class' and ends
Class' keywords.
PublicClass Form l
Private Sub Form1_Load(sender As Object,e As EventArgs) Handles
MyBase.Load
End Sub
End Class
Overview of Visual Studio .NET |Page : 1.17|
If we get this window by double clicking on any part of the form, it also
includes default event procedure of Form named as Form_Load. An event
procedure starts with 'Private Sub' and ends with 'End Sub' keywords. The
'Form 1' class and the event 'Load' are joined together with an underscore to
make Form 1_Load. Here, it is doing nothing other than loading an empty form.
In the arguments of 'Form_Load' procedure, 'Sender' and 'e' are parameters oi
event handlers where 'Sender' contains information about the object which
generated the event and 'e' is the event itself. The code window includes three
drop dowm lists for listing projects, objects of selected controls and events
related to selected object as shown in Figure 1.16.
Figure 1.16 :Code Window
Forrn1.vb (Design 4 Form1.vb* X
Ie WindowsApplication1 Form1 InitializeComponent
EPublic Class Fornl
Oreferences
Private Sub Form1 Load(sender As 0bject, e As EventArgs) Handles MyBase.Load
End Sub
End Class
Each window in VS.NET has three icons on its right side-Window Position, Auto
Hide (thumb tack) and Close as shown in Figure 1.17.
Figure 1.17: lcons on the right of a Window
Window Position
Thumb Tack
X
Close
Window Position has five options. These are given as follows:
(i) Float: When float is selected, the window can be set anywhere. Position can
also be selected as shown in Figure 1.18. Floating windows are always on the
top of other windows. Here, Solution Explorer window is set to Float.
(ii) Dock as Tabbed Document: If Dock as Tabbed Document is selected, the
window is shifted to Tabbed Document area as shown in Figure 1.19. Here,
Solution Explorer window is set to Dock as Tabbed Document.
Page : 1.18 Overview of Visual,
Studio NE
Figure 1.18: Window Position: Float
Shin Eplorer
CWdindyit
dunces
Formi
Different screen
positions toset
windows
Document
Figure 1.19: Window Position: Dock as Tabbed
D WindowsApplication1 - Microsoft Visual Studio
File Edit View Project Build Debug Team Tools Test Analyze Wir
-C- Debug Any CPU
Toolbox
Sources
Data Form1.vb [Design] Solution Explorer X
Search Solution Explorer (Ctrl+;)
VE WindowsApplication1
My Project
I1 References
App.config
Form1.vb
(iv) Dock: Window is fixed to a dock on any one of the four borders of the windot
If the window is to be docked again,right click on tab, select Dock as showni
Figure 1.20. Dock option is chosen for Solution Explorer window.
(v) Hide and Auto Hide: If Auto Hide is selected, the window is hidden as shou
in Figure 1.21. In Auto Hide mode, when window is clicked, the comple
window appears. To bring back the window, click on window, select Do
option from Window Position as shown in Figure 1.22.
Overview of Visual Studio NET Page : 1.19
Fiqure 1.20: Window Position: Dock
DA WindowsApplication1-Microsoft VisUat Stuedie
File Edit View Project Buitd Window
Debug Tearn Toefs Tect Anslyre
Debug Any cPU
Data Forml.vb [Design) Solutie
Cleee CtteF4
Toolbox
Sources
Clese AIL But This
Search Solutien Explorer (Ctte)
Close A But Pinined
[ WindowsApplicationt
Flost
My Project
-References Flost AII
App.config Deck
BE Foml.vb Auto Hicde
Hide
Pin Tab
New Horizontal Tab Group
New Vertical Tab Group
Figure 1.21: Window Position: Auto Hide
Properties Solution
Explorer
4X
Form1 Systern.Windows.Forms.Form
HelpButton False
E lcon (lcon)
ImeMode NoControl
IsMdiContainer False
KeyPreview False
Language (Default)
Localizable False
Location 0,0
Figure 1.22: Window Position: Hide
Properties
S Properties
Float
Dock
Dock as Tabbed Document
Auto Hide
Hide
SMaicontainer False
KeyPreview False
Language (Default)
Orerniew of Visual Studin. NET
Page : 1.20
1.7 INTRODUCTION TO VB.NET
NET) Is an object oriented programming language suppor
Visual Basic NET (VB.
It was launched by Microsoft in 2002. Visual Basic .NET
by NET Framework, backward compatible with VB6 However, lates
VB6, but it is not
successor to
support older versions of NET Frarmework. The m
versions of NET framework Graphical User Interface (GUl, pronounced
Visual refers to the visual appeal of
word is taken from an earlier language Beginners All Purpos.
GOOEY) and the Basic'
Code', The word NET stands for network as this languad
Symbolic Instruction applicationsand services. The main feature
includes functionality for developing web
of VB.NET are as follows
object-oriented programming language as it supports classes
VB.NET is an polymorphism concepts of object-oriente
objects, abstraction, inheritance and
paradigm.
provides Rapid Application Development (RAD) environment which
VB.NET
programmers in developing applications quickly. Programmers do ng
helps appearance of user interface elements
creating
have to spend much time on
rather they can be placed on a Form
such as TextBox, Label and many more,
just by dragging and dropping.
GUIs that can be used as front end for
VB.NET enables programmers to develop components such
visual
database related applications. A typical GUI includes
appeal, GUI based applications
as TextBoxes, Labels and Buttons. Due to visual
called Character User Interface
are preferred over console applications, also
(CUI) applications.
writing code
VB.NET is an event driven programming language. It allows user in
a mousE
which is executed only when a particular event fires such as clicking of
or a key.
modular
7 VB.NET supports procedures and functions for supporting
programming.
VB.NET also provides classes to create web applications and web services. I
becomes easy for the user to learn and develop different types of applications
using familiar interface,
1.7.1 Writing and Executing a VB.NET Program
Visual Basic has two distinct environments, Design Environment and Debug
Environment. In the Design environment, the VB.NET form (program) is designed and
code is written. In the Debug environment, the program is executed and the location
of errors are produced in case of errors in the code. The following steps are carried t0
design and write a VB.NET program.
Overview of Visual Studio .NET Page : 1.21|
> Build a Graphical User Interface
Add controls from the Toolbox to the Form.
Customize the properties of various controls.
> Write code
Write code for the relevant controls so that they can response to events
triggered by the user's actions such as clicking a button or menu option.
Execute or Run VB.NET Project
Click at Debug menu and then Start or Press F5 key.
1.7.2 Introduction to Commonly Used Controls in VB.NET
During the designing of Graphical User Interface (GUI) for the VB.NET program,
controls like Label, TextBox and many more are required. In this section, commonly
used controls - Label, TextBox and Button are given briefly so as to enable a user to
write a small VB.NET project. The details of these controls are given in Chapter 4.
text
º Label Control: The Label control in VB.NET is used to display informative
on the Form.
TextBox Control: TextBox control in VB.NET is used to get user input at run
time. It is also used to display the text.
time
Button Control: Button Control is used to trigger some action during run
button. The Click event of a
on occurrence of an event such as clicking the
and executes the
Button occurs when user clicks on Button during run time
corresponding code.
dragging
These controls are selected from Tool Box and placed on the form either by
and dropping them onto Form or by double clicking them.theyThecanlatter option places
be moved to the
controls on the upper left side of the Form from where
required location.
The two main properties of these three controls are given as follows.
may be a
> Name: This property is used to uniquely identify the object which
label, TextBox or Button.
Text: This property is used for different controls as given below.
For Label control, this property is used to display the text/message on
Screen.
For TextBox control, this property gets or setsthe text from/in theTextBox.
For Button control, this property displays the text assigned to it as Button
caption.
Theproperties of these controls can be set during design time or at run time using
code. The Figure 1.23 shows these three controls on VB.NET form followed by
properties set during design time.
Overview of Visual Studio
Page : 1.22
NET
Properties
Figure 1.23: Demo of Basic Controls and their
B Form1
Label Control
TextBox Control
Label1
Button Control
Button1
Properties
lblvalue Systern.Windows.Forms.Label
Standard
FlatStyle Mictoscft Sans Serf, B.25p
Text property of Label is set to
D Font ControlTet
ForeColor
Enter Value After setting, it looks Image
(none)
like as given below. Similarly, the
MiddleCenter
Imagelign (none)
remaining properties can be set. Imagelindex
(none)
ImageKey
imagelist (none)
No
RightToleft
Enter Value
Tet
TextAlign TopLeft
UseMnemonic True
UceWaitCusor False
Enter Value
Message
1.7.3 Built-in Functions for Displaying a
The most commonly used functions
VB.NET also provides many built-in functions. follows.
are described as
to display user-defined messages
functions are used to
MsgBox(String) or MessageBox.show(String): These
time. The text to be displayed
display a message inside a dialog b0x during run MessageBox.show() is
is passed to these functions. The purpose of MsgBox() and
same. For example,
MsgBox(Hello")
MessageBox.show ("Hello")
1.7.4 The Close() method
This method of Form object is used to close the form. For example,
me.Close() 'where me refers to currently active Form.
1.7.5 First VB.NET Project to Display a Message
Create a project and solution with name FirstVBNetSolution. Add a Button control
and change its text to 'Click Here'. On clicking this button, display a message Welcome
to the World of GUI Application". Add another button with caption Exit. On clicking thiS
Overview of Visual Studio .NET |Page : 1.23
button, close the form. Figure 1.24 shows the design time layout of Form, Solution
Explorer and Property settings.
Figure 1.24: Design Time layout of Form, Solution Explorer and Property Settings
o Form
Solution Explorer Properties
Button1 System.Windows.Forms.Button
Search Solution Explorer (Ctrl+;) (none)
ImageKey
Cick Here Et D FirstVBNetSolution (none)
Imagelist
My Project RightToLeft No
References Text Click Here
App.config MiddleCenter
TextAlign
D Form1.vb TextlmageRelation Overlay
UseMnemonic True
lUseVisualStvleBackCala True
Properties Window
Form Layout Solution Explorer
Form will start its
To execute the Form, click on Start button available at top. The
button Click Here', a
execution. Figure 1.25 shows the run time screen. On clicking
right side of Figure 1.24. When
dialog box with message will appear as shown in the
Then click on Exit button to
button Ok is clicked, the control will come back to form.
close the Form. It will stop execution. Project 1.l shows the code.
Figure 1.25: Run Time Screen and MessageBox()
Form1
Click Here Exit Welcome to the World of GUI Application
OK
Project 1.1: Displaying Welcome Message
Public Class Form1
Private Sub Button1 _Click(sender As Object, e As EventArgs) Handles Button1.Click
MessageBox. Show("Welcome to the World of GUI Application")
EndSub
Page : 1.24 Overview of Visual|
Studio NET
Private Sub Button2 Click(sender As Object, e As EventArgs) Handles Button2.( Click
Me.Close(0
End Sub
End Class
Save the project and solution. The files can be saved in default path or the path o
your choice. The default path is C:|Users\<user name>\Docurnents\ Visual Studis
2015\Projects. Under this default path or path of developer's choice, a folder with
solution name is created.In case of this example, solution nameis'FirstVBNetSolution
and it is stored in e:|vbprojects folder. The physical structure of this solution appear
solution file is stored at one level up of the
as shown in the left side off Figure 1.26. The
hierarchy as shown on right side of Figure 1.26.
Structure of Solution
Figure 1.26: Physical
bin
My Project
obj
Name
App FirstVBNetSolution
e FirstVBNetSolution
FirstVBNetSolution.vbproj FirstVBNetSolution
D Form1.Designer.vb
D Form1
Form1.vb
1.8 DEVELOPING CONSOLE APPLICATIONS IN VB.NET
Console applications are also called Character User Interface (CUI) Applications.
Such applications are easy to develop in comparison to Graphical User Interface (GU|
applications. Aconsole application is used to read input data from console and wrt
output data to console. The Larnguages like Cand Java support console applications.
A console application in VB.NET is executed in DOS environment and it does not
use graphics. It is considered efficient as it consumes fewer resources. When console
application is executed, operating system provides three input and output streams to
console application named as standard input stream, standard output stream and
standard error output stream.
Console applications use a system namespace called Console. The Console
namespace includes methods required to read input and write output from/to consol.
The commonly used methods are described in brief as shown in the Table 1.1.
Overview of Visual Studio .NET Page : 1.25
Table 1.1: Commonly used Methods for Console Applications
Method Description
Write This method writes string to standard output.
Writeline This method writes string to standard output followed by a newline
character.
Readkey This method reads one character at a time from standard input.
Read This method reads next character fromn standard input.
Readline This method reads entire line.
1.8.1 Steps to Develop and Execute a Console Application
(i) Go to File mnenu in the VS.NET IDE
(ii) Select New Project
(ii) Select Template
(iv) Select Visual Basic
(v) Select Console Application
(vi) Give name to console application as shown in Figure 1.27.
Figure 1.27: Creating a Console Application
? X
New Project
Search Installed Templates (Ctrl-E)
Recent NET Framework 4.5.2 Sort by: Default
Type: Visual Basic
4 Installed V Visual Basic
Windows Forms Application
project for creating a command-line
A
Templates application
Visual Basic
4 Visual Basic WPF Application
4Windows
Visual Basic
Universal C Console Application
Windows 8
VE Visual Basic
Classic Desktop Shared Project
Web
Visual Basic
Cloud Class Library
Extensibility
Visual Basic
LightSwitch Class Library (Portable)
Office/SharePoint
Silverlight
Test
WCF
Workflow
TypeScript
D Other Languages
b Other Project Types
Samples
Online
Click here to go online and find termplates.
Name: FirstConsoleApplicationl
OK Cancel
(vii) Click button OK
(viii) A Blank module having name 'Module 1' and extension '.VB' will appear as
shown in Figure 1.28. It has one procedure (subroutine), Main(), which is used
to write code.
Overview of Visual s
Page : 1.26
Studio N
(ix) Write code in 'sub Main()'
(x) To execute console application, click on start button(), Console
will start executing in DOs environment. applicati
Fiqure 1.28: Module Structure
Mde oMe
hole dalel
Sb in()
Bd Sub
End Podole
1.8.2 Console Application Example
Write a console application to read two numbers, add them and write output
console. The source code of the Project is shown in Project 1.2.
Project 1.2: Console Application for Adding Numbers
Module Module 1
Sub Main)
Console.WriteLine('Program to add two numbers")
Console. Write("Enter first number:")
Dim nol = Console.ReadLine()
dim is used to declare variable
Console.Write("'Enter second number:")
Dim no2 = Console.ReadLine)
Console.Write("Addition is ")
Console. WriteLine(CInt(no1) + CInt(no2)
'CINT function is used to convert string to numeric
Console.ReadKey)
End Sub
End Module
The output is as follows.
file:///C:/Users/Indu Arora/AppData/Local/Temporary Projects
Program to add two numbers
Enter first number 2
Enter second number 6
Addition is 8
Overview of Visual Studio NET Page : 1.27
1.9 IMPORTING NAMESPACES
A namespace is a logical grouping of related classes and interfaces of .NET
Framework. They reside in assemblies, which are deployable units containing detais
about classes, interfaces and structures, The first part up to the last dot of the full
name of a type indicates the namespace, while the last part specifies the type name.
For example, 'System.window. Forms' contains classes for creating User interface
elements. Namespaces can be used by any application using imports staterment 1in
NET Framework language.
The Imports statement helps in enabling types that are contained in a gven
or
namespace to be referenced directly. Anamespacc name nay be a single narnespace
the next higher level
a string of namespaces where cach namespace is separated frorn
namespace by a period.
Imports System.Data. OLEDB
level and cannot be used
The Imports statements are used at source code file
procedure or block. However,
within namespace, class, structure, module, interface, statements. These staternents
each source code file can contain any number of Imports
statement. But these staternents
should be written after statements like Option Strict
Imports statement does
must precede declaration statements like Module or Class. The
to a project, but only
not make elements from other projects and assemblies available
project.
removes the need to qualify names that are already available to the
1.10 OBJECT BROWSER
with their properties
Object Browser displays all the objects of an application along
invoked using Ctrl+Alt+J
and methods. This option is available in View menu or can be
key combination.
1.11 CLASS VIEW WINDOW
enumerations,
Class View displays the elements like namespaces, types, interfaces,
window, while lower pane
and classes of an application in the upper pane of its
available in
displays the members of the type selected in the upper pane. This option is
It is shown as part
View menu or can be invoked using Ctrl+Shift+C key combination.
of Solution Explorer or as a separate window.
1.12 SUMMARY
The .NET Framework is developed by Microsoft. It is designed to build Window
based, Web based, console and many more types of applications. Developers can
choose from a variety of programming languages such as VB.NET, C# etc. The object
oriented features make VB.NET more powerful tool to develop and deploy variety of
applications.
Overview of Visual
Page : 1.28
TEST YOURKNOWLEDGE
Sttudis
O Short Answer Questions
.NET Framework.
1. Name main components of
byNET Framework.
2. Name languages supported
3. Describe CTS, CLR and FCL. Visual Studio?
ramework associated with
4. How is NET
5. What is IDE?
Studio. NET?
6. What is Visual
window?
7. What is the use of property the files related to a Solution.
Describe
8. What is a Solution?
Explorer?
9. What is Solution
important files used in VB.NET.
10. Write the extension of
called RAD?
11. Why is VB.NET
VB.NET?
12. What is a Form in
two properties of Label control and Form control.
13. Name any
Text Property of a control.
14. Differentiate between Name and
Designer window and Code Editor window.
15. Differentiate between Form
16. What is a namespace?
console application created?
17. What is a console application? How is a
VB.NET? Explain.
18. How event-driven programming is done in
19. Write about Imports statement.
) Long Answer Questions
1. Accept appropriate input from user in a TextBox;
design suitable Graphic
User Interface for the following and display output using either TextBoxes 0
through MessageBox.
(a) Simple Interest, Temperature Conversion
(b) Area of Circle, Triangle and Rectangle.
2. How are console applications created and executed?
3. Describe main features of .NET Framework.
4. Describe the architecture of NET Framework.
5. Describe main windows of IDE of Visual Studio .NET.
6. List the steps followed to create a VB.NET application.