Computer science
01
Introduction to Visual Basic
Understand what Visual Basic is and what
you
You can do with it. Familiarize and understand the interface of the program
and demonstrate how the tools use.
Specific Objectives
1. Understand Visual Basic.
2. Familiarize and manipulate the Visual Basic IDE.
3. Describe and demonstrate the proper use of visual basic controls.
Materials
Microsoft Word
Computer
Lesson
Introduction
The concept of computer programming
Programming means designing a set of instructions to instruct the computer
to carry out certain jobs that are very much faster than human beings can do.
The earliest programming language is called machine language which uses
the binary code (comprises 0 and 1) to communicate with the computer.
However, the machine language is extremely difficult to learn. Fortunately,
scientists have invented some high-level programming languages that are
1
much easier to master. Among the high-level programming languages are
Java, Javascript, C, C++, c# and Visual Basic.
What is Visual Basic?
Visual Basic is a third-generation vent-driven programming language first
released by Microsoft in 1991. It evolved from the earlier DOS version called
BASIC. BASIC means Beginners’ All-purpose Symbolic Instruction Code. Since
then Microsoft has released many versions of Visual Basic, from Visual Basic 1.0
to the final version Visual Basic 6.0. Visual Basic is a user-friendly programming
language designed for beginners, and it enables anyone to develop GUI
window applications easily.
In 2002, Microsoft released Visual Basic.NET (VB.NET) to replace Visual Basic 6.
Thereafter, Microsoft declared VB6 a legacy programming language in 2008.
Fortunately, Microsoft still provides some form of support for VB6. VB.NET is a
fully object-oriented programming language implemented in the .NET
Framework. It was created to cater for the development of the web as well as
mobile applications. However, many developers still favor Visual Basic 6.0 over
its successor Visual Basic.NET.
The Visual Basic 6 Integrated Development Environment
The Visual Basic environment consists of seven main windows which are:
1. Menu Bar – displays the commands you use to work with visual basic.
Including File, Edit, View, Window, Project, Format, Debug, Help, etc.
2. Toolbar – provide quick access to commonly used commands in the
programming environment.
3. Toolbox – this is where all the controls in visual basic are show and
inserted into the forms.
4. Form Window – this window is where the GUI is designed that will
enable the user to interact with the application.
5. Code Window – this window acts as a code editor for adding, editing or
deleting code.
6. Project window/explorer – serves as a quick reference to the various
elements of a project namely form, classes and modules.
7. Properties window - lists the property settings for the selected form or
control. A property is a characteristic of an object, such as size, caption
or color.
8. Form Layout window – allows you to position the forms in your
application using a small graphical representation of the screen.
2
Menu Bar
Tool Bar
Project
Explorer
Tool Box
Properties
Window
Form Window Form Layout
Window
Standard Toolbar
Button Icon Description
View (host application) Toggles between the host application
and the active Visual Basic Document.
Insert Opens a menu so that you can insert one
of the following objects to your active
project. The icon changes to the last
object you added. The default is the
form.
UserForm
Module
Class Module
Procedure
Save (host document Saves the host document including the
name) project and all of its components (forms
and modules).
Cut Removes the selected control or text and
places it on the clipboard.
3
Copy Copies the selected control or text onto
the clipboard.
Paste Inserts the contents of the clipboard at
the current location.
Find Opens the Find dialog box and searches
for the specified text in the Find What
box.
Undo (last editing Reverses the last editing action.
action)
Redo (last editing Restores the last text editing Undo
action) actions if no other actions have occurred
since the last Undo.
Run Sub/UserForm or Runs the current procedure if the cursor
Run Macro is in a procedure, runs the UserForm if a
UserForm is currently active, or runs a
macro if neither the code window nor a
UserForm is active.
Break Stops execution of a program while it’s
running and switches to break mode.
Reset (project) Clears the execution stack module level
variables and resets the project.
Design Mode Turns design mode off and on.
Project Explorer Displays the Project Explorer, which
displays a hierarchical list of the
currently open projects and their
contents.
Properties Window Opens the Properties window so that
you can view the properties of the
selected control.
Object Browser Displays the Object Browser, which lists
the object libraries, classes, methods,
properties, events and constants that
you can use in code, as well as the
modules and procedures you defined for
your project.
Toolbox Displays or hides the toolbox, which
contains all of the controls and
insertable objects (such as a Microsoft
Excel Chart) available to your application.
4
This is only available when a UserForm is
active.
Microsoft Visual Basic Opens the help viewer for the associated
for Applications Help application.
The Toolbox
Displays the standard Visual Basic controls plus any ActiveX controls and
insertable objects that you have added to your project. You can customize the
Toolbox by adding pages to it or by adding controls by using the Additional
Controls command from the Tools menu. When you add a page, a Select
Objects tool is always available on the page.
Button Icon Description
Select Objects Select Objects is the only item in the
Toolbox that doesn’t draw a control.
When you select it, you can only resize or
move a control that has already been
drawn on a form.
Label (lbl) Allows you to have text that you do not
want the user to change, such as a
caption under a graphic.
TextBox (txt) Holds text that the user can either enter
or change.
ComboBox (cbo) Allows you to draw a combination list box
and text box. The user can either choose
an item from the list or enter a value in
the text box.
ListBox (lst) Use to display a list of items from which
the user can choose. The list can be
scrolled if it has more items than can be
displayed at one time.
5
CheckBox (chk) Creates a box that the user can easily
choose to indicate if something is true or
false, or to display multiple choices when
the user can choose more than one.
Option Button (opt) Allows you to display multiple choices
from which the user can choose only one.
ToggleButton Creates a button that toggles on and off.
Frame (fra) Allows you to create a graphical or
functional grouping for controls. To group
controls, draw the frame first, and then
draw controls inside the frame.
CommandButton Creates a button that the user can choose
(cmd) to carry out a command.
TabStrip Allows you to define multiple pages for
the same area of a window or dialog box
in your application.
MultiPage Presents multiple screens of information
as a single set.
ScrollBar Provides a graphical tool for quickly
navigating through a long list of items or
a large amount of information, for
indicating the current position on a scale,
or as an input device or indicator of speed
or quantity.
SpinButton A spinner control that you can use with
another control to increment and
decrement numbers. You can also use it
to scroll back and forth through a range of
values or a list of items.
Image (img) Displays a graphical image from a bitmap,
icon, or metafile on your form. Images
displayed in an Image control can only be
decorative and use fewer resources than a
PictureBox.
EXERCISES
BASIC
Answer briefly.
6
1. What is Visual Basic program?
2. Why is Visual Basic environment called “Integrated Development
Environment”?
3. Name the seven components in the Visual Basic environment.
Closure
A. Please check the box if you can do it already.
• I can explain what visual basic is;
• I can manipulate and use the controls of Visual Basic properly.
B. If you have questions in mind, please use the space below to address it.
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
References
https://docs.microsoft.com/en-us/office/vba/language/reference/user-
interface-help/toolbox
https://upload.wikimedia.org/wikipedia/commons/b/b8/Visual_basic_6.0.pdf
https://www.vbtutor.net/lesson1.html