Sei sulla pagina 1di 13

Chapter One

1.1 INTRODUCTION TO VISUAL BASIC 6.0

OBJECTIVES:
1. Define Visual Basic programming.

2. Name and define the parts of visual Basic 6.0 graphical interface.

3. Learn the basic concepts and features of Visual Basic 6.0

4. Understand the content of the start up page.

5. Identify and define the functions of form’s anatomy.

Microsoft Visual Basic is developed to create applications for windows the


easiest and fastest way. It simplifies development of programming windows
programs.

The term “Visual” is used to create a Graphical User Interface(GUI)( a picture


based way of interacting with computers). The term basic on the other hand refers
to the language, BASIC which means Beginners All Purpose Symbolic Instruction
Code, the simplest language in the early times of computer programming. Visual
Basic contains hundreds of statements, functions, and keywords, and directly relate
to the Windows GUI. Today, this is the most popular programming language in the
Windows environment.

System Requirements:
• PC with at least 586/66 or higher processor(Pentium or higher processor
recommended) or any alpha processor running Microsoft Windows NT
workstations.

• MS Windows NT OS version 4.0 or later(Service Pack 2 also recommended)

• A hard disk with a minimum of 100 megabytes available space for a full
installation.

• A CD-Rom disk drive

• SVGA or higher resolution screen supported by MS windows.

• 32MB or RAM for Windows NT

• Minimum installation: 35 MB

• A mouse or other suitable pointing device.


Features of Visual Basic
• Like other windows applications, Visual Basic has a graphical user interface
called an integrated development environment (IDE). This includes all
necessary tools to create and test a program. You can create a program,
write the code/statements and test the program while inside the same IDE.

Visual Basic allows the user to use the functionality provided by other
applications such as MS Word, MS Excel and other applications.

• It is an event driven programming language. The word event means an


action that occurs as a result of some activity. This means it respond to
whatever statements such as loading an application or simply by clicking the
button using the mouse or entering values in a text box or any other user
activity. Such causes the program’s statements to execute.

• It is an object oriented programming language. This means that the


programmer can create an object, whereas, the end-user will use to perform
specific task.

• Visual Basic has a well defined structure. Each form created is treated as a
separate file known as a form module. A form module contains information on
instances of controls drawn on the form. A group of statements is referred to
as code.

• Visual basic application supports standard module, which contains


statement where several forms may be used. These modules contain code
written to perform specific actions.

A project file lists each form, as well as the information about the different types
of controls in each form. Note that each program has a single project file,
regardless of the number of modules.

Characteristics of an Object-Oriented Programming


Language
Visual Basic is a Windows based development language. It is recommended
therefore that the user must be familiar with the Windows environment.

1. A programming object is similar to a real-world object. It has predefined


set of characteristics and setting called properties. The user may assign
attributes for the properties of these objects by selecting various
characteristics such as alignment, names and captions from an extensive
list.
2. A program object has predefined set of actions called methods.

3. VB programmers use different tools to create objects called controls. You


can create and manipulate screen objects such as command buttons and
dialog boxes.

Illustration: A program object:

Real world object:

Ball object
----
Color attribute
----
Blue value
----
Roll/bounc method
e

The illustration shows the comparison


between a programming object and a
real-world object. Figure 1.1 Visual Basic Print Setup dialog box and its
features.

A control is classified as a class. A Class is a template for an object, defining the


object supported events, properties and methods. It defines how an object behaves
and what it does.

1.2 GETTING STARTED WITH VISUAL BASIC

How to Start Visual Basic 6.0


• Click Start button > Programs > Microsoft Visual Studio 6.0 > Microsoft Visual
Basic 6.0
The Visual Basic 6.0 start up page
provides options for the programmers. The
Visual Basic Start up page: tabs available onscreen are New (for
creating new program interface) Existing
(for opening all files already created) and
Recent (to view the recently created visual
basic documents).

Standard EXE is most commonly


selected to create an application.

Note: Discussions on other available


options/ templates later in this workbook.
Figure 1.2 shows the Project Wizard’s New Project Dialog box.

You can use any of these tabs to get you started on a project. You may
notice a small checkbox at the bottom part of the start up page saying,
“Don’t show this dialog in the future.” If you prefer not to be bothered with
this page or selecting a type of project, you can check this box, and the
window will not appear the next time you open the Visual Basic application.

Learning the Features of the Visual Basic IDE


Behind the start up page lies the Integrated Development Environment of
Visual Basic 6.0 (See Figure 1.3). The IDE is where the programmers create,
manipulate, run the application.

IDE is a term used to describe the user interface and environment used to
create applications. It is termed Integrated because the programmers can access
virtually all the tools needed from one screen, called an interface. Another
commonly term use to refer the IDE are design environment and/or the program.

The Components of Visual Basic 6.0 IDE


• Menu bar • Form Layout window

• Toolbar • Form Designer

• Toolbox • Object Browser

• Project Explorer Window • Properties Window

The Visual Basic 6.0 Integrated Development Environment (IDE)


Title Menu Tool bar
bar bar
Project
Explor
er
Toolbox

Properti
es
Fig. 1.3 Window

The Integrated
Development
Environment of
Visual Basic 6.0
Properti
es
Window

Visual Basic 6.0 Integrated Development


Environment
Title Bar

The Title bar is at the topmost portion of a program. It normally contains the name
of the application.

Menu bar

The Menu bar holds the total control over Visual Basic application. This also contains
commands used to
create, manipulate and run an application.

Toolbar

The Toolbar is a set of tools available for the programmer. This duplicates many of
the commands in the
menu bar and provides instant access to frequently used commands.
Form Layout Window

The Form Layout window is a window where you create the user interface for the
program. It also shows
the exact location of the form in the Visual Basic IDE.

Toolbox

The Toolbox is a set of drag and drop tools which serve as controls and manipulated
through codes. These drag and drop tools are necessary to create the user interface
for a form.

Close button

Pointer Pointer

Label Text box

Frame Command button

Check box Option button

Combo box List Box

HScroll bar VScroll bar

Timer Drive List box

Directory List box File list box

Shape Line

Image Data

OLE (Object linking


and embedding)
Figure 1.4 shows the Visual Basic toolbox.

Properties Window

This window displays set of attributes and values needed to manipulate controls.

The name and the caption property is said to be the most used and abused
window set of attributes, called properties. Different objects have different set of
properties that includes size, color, alignment, visibility and appearance.

To activate the Properties window:

• Access the View menu > Select Properties window or simply press F4 in your
keyboard. Resize the window if necessary.

Fig 1.5 The Properties Window of a Form Fig. 1.6 The Properties Window of
a command button
Figures 1.5 and 1.6 showing that each control has different properties.

The properties window has two columns. The NAME column, which lists the name of
the property and the VALUE column which lists the current value of a property.

Note: You can use the scroll bar to view the list of properties if the entire list does
not fit within the window.

1. Alphabetic tab allows the programmer to view the properties applicable to


the controls and is presented in alphabetical order.

2. Categorized tab when active, allows the programmer to view the properties
applicable to the controls and is presented by category.

The properties window also has its own title bar and a control box at the top left
portion. The minimize button when clicked, will reduce the Properties window of an
icon. To hide or close this window, click on the X mark button of the control box.
Press F4 to view the window.

Code Window

This window serves as the area that displays the set of BASIC codes or
actions and events assigned by the programmer.
The Visual Basic 6.0 Code Window
Object List
box

Procedure
List box

Codes

Figure 1.7 shows the Visual Basic 6.0 code window

To open the code window, do any of the following:

• Click the Project Explorer window, and click the View Code button or
• Double click the form or any controls in the form or

• Press F7 in your keyboard.

The Two List Boxes of Code Window

• Object List Box. This box shows the objects of the current form and the
difference controls.

• Procedure List Box. This box lists the different event procedures to which the
object can respond. These procedures depend on the types of object selected
for different object respond to different events.

An example of an event procedure:

Event
Procedures

Figure 1.8 shows an example of a Code window event procedure.

How to view the toolbar

• View menu > Toolbars > Customize> Toolbars tab

• Make sure the menu bar and standard toolbar check boxes are checked, then
clear any other check boxes.

How to display tool tip for a Toolbar button

• Position mouse pointer over the Add Standard EXE project at the left portion
of the toolbar.

• The tool tip appears and displays Add Standard EXE Project.

Note: the tool tip disappears when the user moves the mouse pointer away
from the button.
How to configure the Visual Basic IDE

• Tools menu > Options > click the Advanced Tab in the Options dialog.

• Make sure that the SDI Development Environment is not checked.

• Click the Docking tab in the options dialog.

• Click Ok.

The Project Explorer displays the hierarchical list of all forms and modules
created and used in the
project. Each line include the following terms:

- Box contains the plus and minus sign. Plus means opening a folder and
displaying its content. Minus means closing the folder and its content.

- Icon list the type of module.

- Name of the Module

- Filename of the form and module save on the disk

Project Explorer Window


This window provides information about the form you are currently working
with and
options to view the code, the object or toggle folders. It contains the name of
the project and the modules that makes up a project.

The Project Explorer window:


View Toggle
Object Folders

View
Code

Form
Name

Figure 1.4 shows the parts of the Project Explorer Window.

Project Explorer contains three buttons namely:


- View Code button. It opens a window to display events assigned by the
programmer.
- View Object button. It opens the form window and controls created.
- Toggle folders button. It hides and shows the file folder.
How to View the Project Explorer window
Access the View menu> Click on Project Explorer window or simple press Ctrl
+ R in your keyboard.

Form is a window used to create the user interface for any applications. The user
interface may
include menus, dialog boxes, command buttons, and images that is
used manipulate a program.

The Anatomy of a Form


Form object is the most basic object the programmer will be working with.
Basically, it is a window that the programmers can add different elements or
controls in order to create a complete application.

To create a new Form:

• Open Visual Basic > New Project > Standard EXE. You will then see
the various parts of a single form object (See figure 1.5). The next part
will discuss the parts and functions of the form’s anatomy.

Let’s take a look at how these form features are used in Visual Basic
6.0.
Caption Title bar

Control menu

Control box

Border

Figure 1.5 shows the anatomy of a Visual Basic form object.

The Border

The Border is what makes the form elastic by default. The program can program
the form’s border to be fixed, sizable or even nonexistent. This can be set using the
property, BorderStyle.

The Title Bar

The title bar is on top of most forms. This shows the name of the form. You can drag
the title bar to move the window around the screen. In addition, a double click will
alternately maximize and restore the form window.

The Caption

This is the text that you see in the form’s title bar. This is used to identify the name
of the application. The caption to appear in the title bar depends on what the
programmers are trying to achieve.

Note: If the programmer set a form’s BorderStyle property to None, then the
caption will be hidden. You can decide what caption fits your application using the
Caption property in the properties window.

The Control Menu

This is a simple menu that allows the user to restore, move , resize, maximize,
minimize, and close a form. Set the form’s ControlBox property to True in the
properties window to enable this button.
The Control box

This box allows the user to minimize, maximize and close the current window. The
user can control whether the control box will be visible on screen or not.

Working with Form Properties


Properties describe the characteristics of an object. They can be used to manipulate
the identity of the form and its appearance. The following shows the commonly
used properties of the form object:

BackColor ForeColor MinButton

BorderStyle Height Name

Caption Left Width

ControlBox MaxButton WindowState

Potrebbero piacerti anche