ch-2 Overview of Visual
ch-2 Overview of Visual
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
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,
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
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
(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
º 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
IypeScript
Other Languages
Other Project Types
Samples
Online
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
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
(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
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
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
Shin Eplorer
CWdindyit
dunces
Formi
Different screen
positions toset
windows
Document
Figure 1.19: Window Position: Dock as Tabbed
Toolbox
Sources
Data Form1.vb [Design] Solution Explorer X
(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
Pin Tab
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
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")
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
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
OK
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
Name: FirstConsoleApplicationl
OK Cancel
Mde oMe
hole dalel
Sb in()
Bd Sub
End Podole
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
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.