Microsoft Visual Basic 6.
0
Introduction
Visual Basic implements graphical user interface that
allows the use of graphics for different applications. I t
provides visual interactive windows with user, like
Dialogue box for (color, font ...), Input box, and Output
box. Also it is able to create menu to simplify user
application.
To run this program on user computer:
Start>programs>Microsoft Visual Studio 6.0>Microsoft
Visual Basic 6.0.
It will appear on the computer screen as in the following
picture.
To exit from Visual Basic and return to Windows is like
exit from most Windows applications. There are
three ways to close the Visual Basic as stated below.
Click on close button icon that appears in the upper-
left corner of the screen.
Press Alt+F4
Select File >Exit
1.2-The Importance of Visual Basic Program
Languages like Basic and Pascal depend on variables
and procedures to build the applications .This is why it
is called procedural languages. The new approach is
called object programming for visual programs like
Visual Basic and Visual C++ and others. In this
programming approach every thing (form, command
buttons, controls) is an object.
The reasons for of implementing Visual Basic program are listed as
follows:
1.It uses integrated development environment (IDE)
which is easier for the user to minimize code writing.
2.All visual programs follow the same concepts,
therefore the user will become more familiar with
visual approach for other visual languages.
3.It provides Input box and Output box as an interactive
windows with user.
4.It is able to connect to Internet, and to call Explorer.
Elements of the Integrated Development
Environment (IDE)
The IDE environment consists of many elements. Some
elements are displayed when Visual Basic is started (By
default) as in the following figure. Other elements are
displayed if the user requires them. We will list some of
these elements.
g
A. Menu Bar: It contains a standard command like: File, Edit,
View, Window, Help menus, and specific command such as:
Project, Format, or Debug menus.
B. Toolbar: it contains the most commonly used commands
(button), if clicked an action represented by that button is
carried out.
C. ToolBox: it contains a collection of tools that are needed for
project design.
D. form Designer: it is a window for each form to customize the
designed interface of the application. Using the form
designer, the user can add controls, graphics, and text to
create the desired form appearance.
A. Properties Window: it is a List of properties settings for a
selected form or a control. These properties are
characteristics (such as size, visible, or color) of the
selected object it provides an easy way to set properties.
B. Project Explorer Window: it is a list of the forms and
modules for the current projects. lt is a hierarchical tree-
branch structure, where the project at top of tree and
other parts like forms ,modules) descend from this tree.
Form Layout Window: The Form Layout window is a small screen.
Which is used to reposition the form of the application so that it
appears in proper place when project is run.
Code Editor Window: Code Editor Window is used to write a VB code
for an application. For each form there is a separate code editor
window. It is displayed when user clicks on form or object in form
To Create an Application
The title of program includes the name of project, and when
the user first starts the program it takes a defaulted value
(projectl).It also includes resize
icons. The following steps are required to create an
application in Visual Basic 6.0:
Select type of project New or Exciting. A form automatically
appears in the form design .The basis for any application's
interface is the form that user should create. User can add
other forms to the project (to add another form select
project menu>add form).
To add objects (controls) to the form use the ToolBox.
Set the properties for the objects through
properties window.
Write code. The Visual Basic Code consists of
statements, and declarations.
Run the Application. To run the application, click
the Start button on the toolbar, or press F5.
Stop. To stop running the application and return
to visual basic program click on stop button in
tool bar.
Check if there is an error, return to step
3 ,otherwise continue.
Save project.
Exit.
Exercises
Define the following parameters:
a-Toolbar. b-ToolBox.
c-Form designer, d-form layout.
e-project window,
f-properties window.
i- code editor window