05-12-2012, 10:55 AM
Visual Basic Tutorial
VBTutorial.pdf (Size: 939.09 KB / Downloads: 205)
A brief description of Visual Basic
VISUAL BASIC is a high level programming language evolved from the earlier DOS version called BASIC.
BASIC means Beginners' Allpurpose Symbolic Instruction Code. It is a fairly easy programming language to
learn. The codes look a bit like English Language. Different software companies produced different version of
BASIC, such as Microsoft QBASIC, QUICKBASIC, GWBASIC ,IBM BASICA and so on.
VISUAL BASIC is a VISUAL and events driven Programming Language.These are the main divergence from
the old BASIC. In BASIC, programming is done in a text-only environment and the prgram is executed
sequentially. In VISUAL BASIC, programming is done in a graphical environment. Because users may click on
a certain object randomly, so each object has to be programmed indepently to be able to response to those
actions(events).Therefore, a VISUAL BASIC Program is made up of many subprograms, each has its own
program codes, and each can be excecuted indepently and at the same time each can be linked together in one
way or another.
The Visual Basic Environment
On start up, Visual Basic 6.0 will display the following dialog box as shown in figure 1.1.
You can choose to start a new project, open an existing project or select a list of recently opened programs. A
project is a collection of files that make up your application. There are various types of applications we could
create, however, we shall concentrate on creating Standard EXE programs(EXE means executable program).
Now, click on the Standard EXE icon to go into the actual VB programming environment.
Creating Your First Application
In this section, we are not going into the technical aspect of VB programming, just have a feel of it. Now,
you can try out the examples below:
Example 2.1.1 is a simple program . First of all, you have to launch Microsoft Visual Basic. Normally, a
default form Form1 will be available for you to start your new project. Now, double click on form1, the
source code window for form1 will appear. Don't worry about the begining and the end statements(i.e
Private Sub Form_Load...End Sub.); Just key in the lines in between the above two statements
exactly as are shown here.When you run the program, you will be surprise that nothing shown up.In
order to display the output of the program, you have to add the Form1.show statement like in Example
21.2 and Example 2.1.3. Try them out.
Working With Controls
Before writing an event procedure for a control to response to a user's action, you have to set certain
properties for the control to determine its appearance and how it will work with the event procedure. You
can set the properties of the controls in the properties windows. I am not going into the details on how to
set the properties. However, I would like to stress a few important points about setting up the properties.
l You should set the Caption Property of a control clearly so that a user know what to do with
that command. For example, in the calculator program, all the captions of the command buttons
such as +, - , MC ,MR are commonly found in an ordinary calculator, a user should have no
problem in manipulating the buttons.
l You should set a meaningful name for the Name Property because it is easier for you to write
and read the event procedure and easier to debug your program later.
l Another property that is important is whether you want your control to be visible or not at start
up.This property can only set to be true or false.
l One more important property is whether the control is enabled or not.
Managing Visual Basic Data
There are many types of data we come across in our daily life. For example, we need to handle data such
as names, adresses, money, date, stock quotes, statistics and etc everyday. Similarly In Visual Basic, we
are also going to deal with these kinds of data. However, to be more systematic, VB divides data into
different types.