Introduction To Visual Basic
Introduction To Visual Basic
TOPIC II
What is Visual Basic?
Microsoft® Visual Basic is an object-based programming language
(Haggard, Hutchison, & Shibata, 2013).
Interface of Visual Basic
Integrated Development Environment
of Visual Basic
Menu Bar
This Menu Bar displays the commands that are required to
build an application. The main menu items have sub menu
items that can be chosen when needed. The toolbars in
the menu bar provide quick access to the commonly used
commands and a button in the toolbar is clicked once to
carry out the action represented by it.
Toolbox
The Toolbox contains a set of controls that are used to
place on a Form at design time thereby creating the user
interface area. Additional controls can be included in the
toolbox by using the Components menu item on the
Project menu. A Toolbox is represented in figure 2 shown
below.
Project Explorer
Docked on the right side of the screen, just under the tollbar,
is the Project Explorer window. The Project Explorer as
shown in in figure serves as a quick reference to the various
elements of a project namely form, classes and modules. All
of the object that make up the application are packed in a
project.
Properties Window
Docked on the right side of the screen, just under the tollbar,
is the Project Explorer window. The Project Explorer as
shown in in figure serves as a quick reference to the various
elements of a project namely form, classes and modules. All
of the object that make up the application are packed in a
project.
Toolbox
Control Description
Provides a way to move and resize the controls
Pointer
form
Displays icons/bitmaps and metafiles. It displays
PictureBox text or acts as a visual container for other
controls.
TextBox Used to display message and enter text.
Serves as a visual and functional container for
Frame
controls
Toolbox
Control Description
Used to carry out the specified action when the
CommandButton
user chooses it.
CheckBox Displays a True/False or Yes/No option.
OptionButton control which is a part of an
OptionButton option group allows the user to select only one
option even it displays mulitiple choices.
Displays a list of items from which a user can
ListBox
select one.
Toolbox
Control Description
HScrollBar and These controls allow the user to select a value
VScrollBar within the specified range of values
Executes the timer events at specified intervals
Timer
of time
Displays the valid disk drives and allows the user
DriveListBox
to select one of them.
Allows the user to select the directories and
DirListBox
paths, which are displayed.
Toolbox
Control Description
Used to add shape (rectangle, square or circle)
Shape
to a Form
Line Used to draw straight line to the Form
used to display images such as icons, bitmaps
Image and metafiles. But less capability than the
PictureBox
Enables the use to connect to an existing
Data
database and display information from it.
Toolbox
Control Description
Used to link or embed an object, display and
OLE manipulate data from other windows based
applications.
Displays a text that the user cannot modify or
Label
interact with.
Control
A control is a tool used to create objects on a Visual Basic
form. A toolbox of controls is available for use to create
objects.
Property
A Property is a characteristic of an object.
Example of Properties:
Caption - is a property of a command button, Label, Option
Button, Check Box, etc.
Text - is a property of a Text Box object.
Name - is a property of a particular object.
Value - is a property of a Horizontal Scroll Bar
Event Procedure
An event procedure is a block or set of code that are executed when an
object is manipulated by the user.
A procedure is a block of Visual Basic statements enclosed by a
declaration statement ( Function, Sub, Operator, Get, Set) and a
matching End declaration.
Program Statement
A program statement is a line of code that does the work of the
program.
Example1 Setting Property values
Label1.Caption="Hello"
Data Types
UserName=txtUserName.Text
sum = num1 + num2
hisName=”George Clooney”
TxtUserName.Text = hisName
Variables
X = 12
lastName=”Jones”
firstName=”Catherine Zeta”
nickName=”Alias”
fullName=”Jennifer Garner ”
nickName2=”Sydney Bristow”
Variable Declaration in Visual Basic
You declare a variable to specify its name and characteristics. The declaration
statement for variables is the Dim Statement.
Example:
Dim x as Integer
Variable Scope
Local Variable
Global
Variable
Combo1.AddItem