Vous êtes sur la page 1sur 10

Project Explorer

The Project Explorer can be found in the top left portion of the Microsoft Visual Basic window.
It is a hierarchical listing of the objects recognized by VBA.

If the Project Explorer is not visible when you open the Microsoft Visual Basic window, you can
make it visible by selecting Project Explorer under the View menu.

In the example below, there are two "Microsoft Access Class Objects" - one is a form called
frmProducts and the other is a report called rptCategories_Report.

In addition, there is one Module called Module1.


VB'S IDE Environment
This lecture focuses on the main components of
Tool bar
Tool box
the Visual Basic environment. By the end of this

Form Window session you should be able to navigate


Code window competently and use many of the functions that
Project explorer are important in the development of an
Properties window application.
Running the application

Visual Basic is used to develop 'rapid applications' inside a windows environment.


When we talk about windows we tend to use the term 'object oriented' to describe
some of its capabilities. Visual Basic is different from programming languages such
as C, Pascal and QBasic, its approach is to respond to events. Visual Basic will allow
you to create applications which allows you to
Develop commercial applications, for example databases and the internet

Links to other products such as Word, Excel and Access

Multimedia applications

Microsoft Visual Basic uses the principles of the BASIC language (Beginners All-
Purpose Symbolic Instruction Code). Due to the advancement of windows
programming Microsoft developed the Visual Basic programming language. The
emphasis on Visual Basic is to develop Windows applications, an example is shown
below (Figure 1.1):

Figure 1.1
The diagram shows a
typical Graphical User
interface which has been
created using Visual Basic.
An application like this can
take only a couple of hours
to create!

The programming created in Figure 1.1 requires an environment where we


can create and modify the application. This is known as the Integrated Development
Environment and is discussed in the next section below.

The Visual Basic Integrated Development


Environment
Visual Basic is a high level programming paradigm. Its concepts are based upon Event
driven programming. The environment to edit, delete and write code as well as
develop windows based applications is known as the 'Integrated Development
Environment' (IDE). The development environment for Visual Basic is illustrated
below in figure 1.2:

Figure 1.2
From the diagram it can be seen that the IDE is divided into separate areas or 'windows'. We
have the Toolbox control which allows us to add objects on to Form window. We can change
the properties using the properties windows for all the objects on the form. We can also
edit/create the event handlers using the Code Window. When creating applications in Visual
Basic it is quite common to use multiple forms, modules etc. The project explorer window is
used to keep track of all the additional files used.
The main components of the Integrated Development Environment (IDE) are
illustrated in the subsequent text.

The Toolbar

Visual Basic supports multiple toolbars which are split into three main areas

Standard toolbar

Edit toolbar

Debug toolbar

You are able to customise the toolbar by clicking the right mouse button of the toolbar
and selecting <Customize> and changing the options you require. The diagram and
components of the standard toolbar are illustrated below:
The Toolbox

The diagram below shows the main tools that appear on the standard Toolbox
window. These are called the intrinsic controls because all three editions of VB
support these standard tools. You can add additional controls to the toolbox as your
needs grow. Some extra tools come with all three editions of VB, but these extra tools
do not appear on the Toolbox window until you add them through the <Project |
Components> menu option.

For resizing forms and controls (a tool for


Pointer
selection and manipulation of objects
Label For changing text such as captions
Purely visual effect (used to group check boxes or
Frames
option buttons
Check Box For binary options
Combo Box Combination of list box and text box
Can be used to control animations or timing
Timers
events (often invisible)
Picture Boxes Allows the inclusion of bitmaps, icons on a form
Provide a standard way for accepting user input
Text Boxes
through the keyboard
Command Standard Window command buttons such as 'OK'
Button and 'Cancel'

All standard components of Windows interfaces can be created here. The Toolbox is
selected by choosing Toolbox menu from the View menu.
The Form Window

The Form window is your primary work area where the visual development of the
application is created or modified. Although the Form window first appears small
relative to the rest of the screen, the Form window comprises the background of the
application.

The form window shows the main body of


the application. The form can be resized to
take up the width of the screen. Here
objects are placed on to the form such as
the command buttons, labels, text
boxes, scrollbars, and other controls to form
the main elements of the Graphical User
Interface.

Note:It is important when creating an interface to use a appropriate design


methodology and avoid taking an 'objects on the screen' approach.

The Code Window

The Form window holds the program's interactive objects, to view the code for
the Form window or any object we can Select <View | Code >. The Code window is
little more than a text editor with which you write the programming statements that tie
the application together.

An alternative technique to view the code is to double click anywhere on the form or
the object and view the code for that particular object. The diagram shows the Code
Window for the form.

Source program is code, forms,


menus, graphics, and help files
that you create and edit to form
the project (also called source
code).

The parts of the application that you create, such as the forms, the code, and the
graphics that you prepare for output, comprise the source program. The code listing
below gives an example of code that is incorporated in a typical application:

Private Sub txtJAN_KeyPress(KeyAscii As Integer)


Call TEST(KeyAscii, txtFEB)
End Sub
_______________________________________________
When you or another user compiles or runs the source program, VB translates the
program into an executable program. You cannot make changes directly to an
executable program. If you see bugs when you run the program, you must change the
source application (which might contain multiple files in the project) and rerun or
recompile the source.
The Project Explorer Window

The Project Explorer window, often called the Project window,


gives you a tree-structured view of all the files in the
application. Microsoft changed the formal name from Project
window to Project Explorer window between versions 4 and 5.

The Project Explorer was used to celebrate the resemblance of the window to the
typical Explorer-like tree-structured file views so prevalent in Windows 95 and
98/2000. You can expand and collapse branches of the view to get more or less detail.

The Project Explorer window displays forms, modules (files that hold supporting
code for the application), classes (advanced modules), and more. When you want to
work with a particular part of the loaded application, double-click the component in
the Project window to bring that component into focus.

In other words, if the Project Explorer window displays three forms and you need to
edit one of the forms, locate and double-click the form name in the Project window to
activate that form in the Form window.

The Properties Window

The property window represents an objects associated properties. Each property of a


control such as a Label, command button etc. has its own unique set of properties.
A different list appears in the Properties window every time you
click over a different Form window object. The Properties
window describes properties (descriptive and functional
information) about the form and its controls. Many properties exist
for almost every object in Visual Basic. The Properties
window lists all the properties of the Form
window's selected control.

Vous aimerez peut-être aussi