Banner Image About Visual Basic Lesson Information User Information guide/help on the site Return to Visual Basic Home Page Go to Previous Page Go to Next Page This course includes lectures on Microsoft Access

Lecture 1 - What's Visual Basic About?

VBA Governance
Whats VB About
Data Types
Decision Making
Case Statements
Message Boxes
Error Handling
Frame Options
Combo Boxes
Scroll bars
Local variables
File List
File Handling
Timer Controls
String handling
Menu Control
Database Programming
Common Dialog Control
VB'S IDE Environment
Tool bar
Tool box
Form Window
Code window
Project explorer
Properties window
Running the application

This lecture focuses on the main components of the Visual Basic environment. By the end of this session you should be able to navigate competently and use many of the functions that are important in the development of an 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):

This is an example of the Application 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:

Visual Basic Integrated         Development environment
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:

Diagram showing the major components of the toolbar

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.

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

Form window

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.

Code Window

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.

Properties window

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.


The property window is viewed by pressing the shortcut key F4.

The chapter focused on the Visual Basic environment. Describing the main components of the application, including the Toolbox, properties windows and Code Window. These environments will be used throughout the duration of this course.

Running the Application

To run the application


You are not authorised to use this material without the written permission of the author. The contents of this material must not be distributed or used for any teaching purposes. Failure to comply may result in criminal prosecution. Go to Previous Page Go to Next Page Contact Vas Rabani for any comments on the website or queries