Lesson 3.1
Lesson 3.1
Lesson 3.1
9
accomplished visually,
in 2002 – introducing a very different object-oriented language without actually writing
any code.
based upon the Microsoft .NET framework. This controversial
edition broke backward-compatibility with previous versions,
causing a rift in the developer community.
• Visual Basic 8.0 (a.k.a.Visual Basic 2005).
• Visual Basic 9.0 (a.k.a. Visual Basic 2008).
• Visual Basic 10.0 (a.k.a. Visual Basic 2010).
• Visual Basic 11.0 (a.k.a. Visual Basic 2012).
• Visual Basic 12.0 (a.k.a. Visual Basic 2013).
(Version numbering of Visual Basic skipped 13 to keep in line
with the version numbering of Visual Studio itself.)
• Visual Basic 14.0 (a.k.a. Visual Basic 2015).
• Visual Basic 15.0 (a.k.a. Visual Basic 2017).
• Visual Basic 16.0 (a.k.a. Visual Basic 2019).
All examples in this book are created for Visual Basic 16.0
although many of the core language features are common to
previous versions of the Visual Basic programming language.
Getting started
Component Requirement
Installation of Visual
Studio is handled by an
installer application. You
can re-run the installer
l4 Open your
Downloads
folder, then
11
click on the
installer file
icon to fetch
some setup
files
Choosing a different
destination folder may
require other paths to
be adjusted later – it’s
simpler to just accept the
suggested default.
Menu Bar
Toolbar
Solution Explorer
• Menu
13
Bar – where you can select actions to perform on all
your project files and to access Help. When a project is open,
extra menus of Project, and Build, are shown in addition to
the default menu selection of File, Edit, View, Debug, Test,
To change the color,
Analyze, Tools, Extensions, Window, and Help.
choose the Tools,
• Toolbar – where you can perform the most popular menu
actions with just a single click on its associated shortcut icon.
Options menu then
select Environment,
•
General, Color Theme.
Toolbox – where you can select visual elements to add to a
project. Click the Toolbox side bar button to see its contents.
When a project is open, “controls” such as Button, Label,
CheckBox, RadioButton, and TextBox are shown here.
• Solution Explorer – where you can see at a glance all the files
and resource components contained within an open project.
• Status Bar – where you can read the state of the current
activity being undertaken. When building an application a
“Build started” message is displayed here, changing to a
“Build succeeded” or “Build failed” message upon completion.
Getting started
l
GettingStarted
2 Next, you must choose “Language”, “Platform”, and
“Project type” – select Visual Basic, Windows, Desktop
14
Visual Studio now creates your new project and loads it into the
IDE. A tabbed Designer window appears displaying a default
empty Form. You can select the View, Solution Explorer menu
to open a Solution Explorer window that reveals all files in your
project, and you can select the View, Properties Window menu
to open a Properties window listing all properties of your Form.
Designer
15
Solution Explorer
Properties window
l
fixed in place so it will
never hide, using the 2 Next, click View,
pin button on the
Toolbox on the Menu
Toolbox bar.
Bar, or click the Toolbox
side bar button, to
display the Toolbox
categories
expansion arrow
beside the Common
If no controls are visible Controls category
in the Toolbox, right- heading to expand the
click on the Toolbox then list of visual controls.
choose Show All to
Usefully, each control
reveal the categories.
name appears beside
an icon depicting that
control as a reminder.
You can click on the
Common Controls
category heading again
to collapse the list, then
expand other categories
to explore the range
of controls available to
Any pinned Window in
the IDE can be dragged
build your application
from its usual location to interfaces
any position you prefer.
Drag it back to the initial
location to re-dock it.
…cont’d
17
The Button control behaves in a familiar Windows application
manner, with “states” that visually react to the cursor: This Button control
performs no function
when it’s clicked – until
you add some code.
l
Switch easily between
the Code window and 1 Double-click on the
Designer window
Button control you have
by clicking on the
appropriate window tab.
added to the default
Form in the Designer
window. A new tabbed
text window opens in
the IDE – this is the
Code editor window
l
18
l 3 Click the Start button to run the application and test the
code you have just written to handle the event that occurs
when the button is clicked
19
l 4 Push the OK button to close the dialog box, then click
the X button on the Form window, or click the Stop
Debugging button on the Menu Bar, to stop the program
Saving projects
Even the simplest Visual Basic project comprises multiple files
that must each be saved on your system to store the project.
Follow these steps to save the current project to disk:
l
open at any given time
2 In the Open Project/Solution dialog, select the folder to avoid confusion –
containing the project you wish to reopen, and Open it unless several are needed
to be open together for
advanced programming.
21
l 3 Select the Visual Basic Solution file with the extension
.sln to reopen the project, or open the folder bearing the
project name then select the Visual Basic Project File
with the extension .vbproj to reopen the project
If you don’t see the
Designer window after
you have reopened a
project, click on the
MainWindow.xaml
icon in Solution
Explorer to make it
appear.