0% found this document useful (0 votes)
3 views7 pages

Event Driven Programming

Uploaded by

kaneno karabu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

Event Driven Programming

Uploaded by

kaneno karabu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

COURSE OUTLINE EVENT DRIVEN PROGRAMMING

Types:
1. INTRODUCTION TO VISUAL BASIC Sequence
PROGRAMMING LANGUAGES Selection
Description of V.B Iteration / repetition
Example of V.P.L Implementation of data structures
Visual basic 6. ERROR HANDLING
Visual c++ Types of errors
Delphi
Hardware and software constructions for V.P
2. VISUAL ENVIRONMENT
Description of visual environment -Syntax
Description of intergrated development -Run time
environment (IDE) -Semantics
Visual objects -Logical
Form window Error handling techniques.
Properties window Writing error handlers
Immediate window On error resume
Code window On error to go
Others Error object
3. PROGRAM STRUCTURE Debugging tools
Format of Visual Program 7. SUB-PROGRAM
Data types Meaning of sub-program
Operators Types of sub-programs
Arithmetic Private sub program
Logical Public sub-program
Comparison Scope of variables
Others Local variables
Variables Global variables
4. PROGRAM WRITING 8. DATA STRUCTURES
Creating an application Data structures
Compilation Types of data structures
Debugging 10. EMERGING TRENDS IN VISUAL BASIC.
Testing Emerging trends in visual programming
Execution Challenges of emerging trends in Visual Basic
5. CONTROL STRUCTURES  Coping with challenges of emerging
Types of control structures trends in visual programming.
Definition
Content
Lecture one
1. Introduction to visual Basic 6.0
Visual Basic
It is a programing language and development environment that allows you to create programs
that run under windows Os. With VB you can create programs that interact with the
Databases, interact with internet and even with hardware.
Event Driven Programing
V.B is event driven, meaning the code remains idle until called upon to respond to some
event. An event can be a mouse click, a key press, menu selection etc. V.B is governed by
an event processor. Nothing happens until an event is detected. Once an event is detected the
code corresponding to that event (event procedure) is executed.
Terminologies
a) Forms
Are windows that you create for user interface. A form generally has many different controls
placed upon it.
b) Controls
Are graphical features drawn on forms to allow user interaction, examples are textboxes
labels, scrollbars command buttons etc. Forms and controls are sometimes collectively
known as objects.
c) Properties
Every characteristic of a form or control is specified by a property, examples of properties
include name, caption, size, color, position and content.
d) Methods
Is a built-in procedure that can be invoked to impart some action to a particular object e.g
print method. Example: Me.print sum ‘displays value held by the variable sum in the
current form.
e) Event Procedure
Is a code related to some object. This is the code that is executed when a certain event occurs.
f) General Procedure
Is code not related to objects. This code must be invoked by the application.
g) Module
It is a collection of general procedures, variable declaration and constant definitions used by
T he application.
h) Application
Is a collection of objects that work together to accomplish something useful. In Vb the
application is called a project. A project could be the management of a video store,
calculation of mortgages etc.
i) Object
Is a piece of s/w that has properties and functions that can be manipulated.

Lecture two
2. VISUAL OBJECTS
a) Visual Basic Integrated Development Environment (I.D.E)
I.D.E is a VB screen in which one can develop, run, test and debug applications. It contains
the elements with which you can develop the user interface of your application.
Elements/components/parts of IDE (Visual Objects)
1. Menu bar
It displays the commands you need to work with VB. Menus are provided for standard
actions like: file, edit, view, window and help and to access functions specific to
programming such as: project, format and debug
2.Standard Toolbar
The standard toolbar has the standard icons that are shortcut command to the menu bar
commands. They provide quick access to commonly used commands in the programing
environment.
3.Toolbox
It contains a set of tools that can be used at design time to place controls on a form
4.Project Window
This window lists the forms and modules in your current project.
5. Properties window
This window lists the property settings for the selected form or control. The properties are
characteristics of an object such as name, size, color, caption etc.
6. Form layouts window
It shows where (upon program execution) your form will be displayed relative to your
monitor’s screen.
7. Code editor window
The code editor window is used for entering and editing the programing code for the
application. Each form has its own code editor window. By double clicking on an object the
corresponding code editor window will open.
8. Immediate, local and watch windows
These windows are included in the IDE for use in debugging your application. They are
available only when you are running your application.

b) Controls
Are graphical features drawn on forms to allow user interaction .it is a tool used to display
information or retrieve information from the user.
Control types
1. Standard controls
Are controls always present in the toolbox
2. Custom controls
Are brought into the VB environment when needed and they extend one tool box.

Description of the roles of various controls


Pointer Is a tool used to select an object to be worked on
Picture box Is used to display graphical objects or text and to initiate event actions. It is similar to an
image box but has more properties, redraw slower and cannot be stretched
Label
Displays a text on a form. The text cannot be reassigned during program execution though its
appearance can be altered during the program execution though its appearance can be altered
Text box
Provides a means of entering or displaying text. The text may be already available or can be
entered during the program execution.
Frame
Used as a container of a group of controls
Command button
Used to activate an event driven procedure.
Check box
Used if more than one selection is to be made.
Option button
Are used when one selection must be made before an action is carried out.
Combo box
Is a special type of list box that combines the capabilities of a text box and a list box. It
provides a list of text item for selection by the user during program execution. Items can also
be added during program execution.
List box
Provides a list of text items for the selection by the user.
Horizontal scroll
Is used for drawing horizontal scrollbars on a form.
Vertical scrollbar
Is used for drawing vertical scrollbar on a form.
Timer
Allows timed events to occur repeatedly at a specific time interval
Drive list box
Provides a way of selecting a drive from a list of existing drivers
Directory list box
Provides a way of selecting a directory from a list
File list box
Provides a way of selecting files within a group of files.
Shape tool
Is used to draw; circles, eclipses, squares and rectangles within forms
Line tool
Is used when drawing straight lines within forms.
Image box
Is used to display graphical objects
Data control
It provides a means of displaying information from existing database.
N/B: The number of tools available on the tool box depends on edition and release of VB
you are using.

Saving a VB project
Saving a VB project is different from other applications because VB operation involves
saving multiple files
a) To save a VB project for the first time, select the save project as command from the
file menu. The save file as dialogue box appear. You will have to enter a form name
and then click the same button, the form is saved with an extension .frm
b) After this the save project As dialogue box appears. Type the name of the project and
it will be saved as file with extension. vbp
Opening an existing project
You can open a project when VB starts or from the file menu. To open a project during start
up from the new project dialogue box that appears when VB is starting, click the existing
tab. A list of existing projects will be displayed. If VB is already running close all other
projects then click open project command on the file menu. The open project dialogue box
appears from which you can select the existing tab

3. PROGRAM STRUCTURE
VB FUNDAMENTAL CONCEPTS
Data types
Data types Description
Integer A whole number with no fraction part. Integer range from -32768 to 32767
Long
Integer Numbers which are integers but have bigger values and range. They range
from -2,147,483,648 to 2,147,483,647
Single A single precision real constant includes a fractional part. The largest value is
3.4 x 1038
Double It includes a fractional part but has far much larger magnitude than the single
real number constant. However it cannot be larger than 1.2 x 10308
String Characters enclosed in quotation marks
Boolean Data types that have only two logical states i.e true or false
Constants
A constant is a value that remains the same. It does not change during program execution.
There are three types of constants; string, numeric and named constants.
String constants
Is a sequence of characters enclosed in quotation marks.They are used to write non-numeric
values like telephone numbers, addresses and names
Numeric constants
Are either whole numbers (integer), double or single
Named constants
Is identified by name rather than its actual values, const keyword is used declare this type of
constants
VARIABLES
A variable is a memory location referred to by name used to hold a value that is subject to
change during program execution. In VB the following rules should be followed when
naming variables:
1. The variable name must not have more than 255 characters
2. The variable name must start with a letter.
3. The letter case is not important when declaring variables
4. A variable name must not be a reserved word
5. Variable names should not have spaces.
A variable is declared using the reserved word DIM the short form of the word dimension
(size). It is used to associate a variable with a specific data type e.g Dim First_Name as
String means that the variable first name is of the type string.
VARIANTS
Is a variable whose data types has not been explicitly declared by the program. They are
called variants because their data types keeps on changing with the values they hold
Scope
Refer to the level of the program that a variable, a constant or a procedure is recognized. The
scope of a variable constant is said to be global or local. The scope of the procedure, variable
or constant is set by declaring it as either private or public. The following terms are used in
this regard:
1. Private sub-procedure
2. Public
3. Global variables / constants
4. Local variables
A public procedure can be accessed from any module or form in the program while private
procedure is accessed in the module or form within which it is declared.
A variable or constant that is declared outside the standard module but within the same
project is said to be global.
User defined data types.
Is a data type whose individual components are standard data items
Using suffixes to declare variables and constants.
Suffixes are special symbols appended to the end of a variable constant name in order to
associate them with a particular data type
Examples
Suffix Data type Long Declaration Short declaration
% Integer Dim A as integer A%
! Single Dim X as single X!
$ String Dim A as string Q$
& Long integer Dim C as long integer C&
# Double Dim P as double P#
Operators
They include;
i. Arithmetic
ii. Relational
iii. Logical
Arithmetic operators
Are special symbols that are used to write arithmetic expressions.
Symbol Name Operation
+ Plus sign Addition
- Minus sign Subtraction
* Asterisk Multiplication
/ Slash Division
^ Caret Exponentiation
\ Backslash Integer division
MOD Modulus Integer remainder
N/B: The last two rows can be explained as follows
1. In an integer division, each of the numbers being divides is first rounded to become an
integer then the quotient is truncated to an integer.
2. The MOD operator returns the remainder of an integer division.
Operators Precedence / Hierachy
Arithmetic operators have the following order of precedence when used in a program
Exponentiation, Multiplication and Division , integer division, integer remainder, addition
and subtraction.
i. Relational Operators
Is used in an expression that returns a true or false value when evaluated. The operators can
compare numeric variables, constants or expressions.
Operator Name
= Equal to
<> Not equal to
> Greater than
< Less than
<= Less than or equal to
>= Greater than or equal to
Logical operators
Operator Operation
And Results in a condition that is true if both expressions are true
Or Results in a condition that is true if one of the condition is true or both are true
Xor Results in a condition that is true if one of the condition is true and the other is
false
Not Negates the value of a logic expression

You might also like