Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
19Activity
0 of .
Results for:
No results containing your search query
P. 1
LESSON 1 - Introducing Visual Basic

LESSON 1 - Introducing Visual Basic

Ratings:

5.0

(1)
|Views: 841|Likes:
Published by api-3709816

More info:

Published by: api-3709816 on Oct 16, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

INTRODUCING VISUAL BASIC
1

Visual Basic is educed from the BASIC programming language. Visual Basic is a distinctly different language providing powerful features such as graphical user interfaces, event handling, object-oriented features, structured programming, and much more. Visual Basic programs are created in an Integrated Development

Environment (IDE). An IDE allows the programmer to create and debug Visual Basic programs conveniently.
Visual Basic is anobject-oriented programming development system for creating applications under any of
the Microsoft Windows environments. It has the following two major components:
1.An extensive collection of prewritten tools, calledcontrols. These controls are accessible as icons
within a graphical programming environment for creating customized windows components (e.g.,
menus, dialog boxes, text boxes, slide bars, etc.).

2. A complete set of program commands, derived from Microsoft\u2019s implementation of the classical BASIC programming language. The command set includes features that embrace modern-day programming practices.

The overall approach to Visual Basic programming is two-fold:
1. Create a user interface that is appropriate to the particular application at hand.
2. Add a group of Basic instructions to carry out the actions associated with each of the controls.

In traditional computer programs, the actions are carried out in a prescribed order. This order may be sequential, corresponding to the order in which the instructions have been specified. In either case, the order of execution is determined internally within the program.

Visual Basic, on the other hand, is based upon anevent-driven paradigm, in which each feature included within the program is activated only when the user responds to a corresponding object (i.e., an icon, a checkbox, an option button, a menu selection, etc.) within the user interface. The program\u2019s response to an action taken by the user is referred to as anevent. Anevent is a signal that informs an application that something important has occurred. It is an action which you can respond to, or \u201chandle\u201d in code. Events can be generated by a user action, such as clicking the mouse or pressing a key; by program code; or by system. Note that the user initiates the event, but it is the program\u2019s response that actually defines the event. The group of Basic commands that brings about this response is called anevent-procedure.

Event-procedures are Visual Basic procedures that respond to events and are automatically generated by
the Visual Basic. The programmer adds code to respond to specific events, and only events that are
relevant to a program need be coded.
In addition to events and event-procedures, you must understand the meaning of each of the following
terms:
FORMS. In Visual Basic, a window is called aform. Each form includes a title bar at the top. A form may
also include a menu bar, a status bar, one or moretoolbars, etc. Some applications are based upon a single
form, while others require two or more forms.
Information and Communication Technology Department
Palompon Institute of Technology
1
What is Visual Basic?
Events and Event-Procedure
Object-Related Concepts
INTRODUCING VISUAL BASIC
1
CONTROLS. The icons with which the user interacts are calledcontrols. Commonly used controls include
command buttons, option buttons, checkbox, labels, textboxes, and menus. The user will typically activate a
control (e.g., click a command button) to produce an event.
OBJECTS. Forms and controls are referred to collectively asobjects. Most objects are associated with
events; hence, objects may include their own unique event procedure. Objects are also associated with their
ownproperties andmethods.
PROPERTIES. Objects includeproperties that generally define their appearance or behavior. The choice or
properties depends on the type of object. For example, the name, caption, height, width, background color,
location and font are some of the more common properties associated with a command button.
Common properties of Visual Basic controls:
Property
Description
Left
The position of the left side of a control with respect to its container.
Top
The position of the top of a control with respect to its container.
Height
A control\u2019s height.
Width
A control\u2019s width.
Name
The string value used to refer to a control.
Enabled
The Boolean (true/false) value that determines whether users can manipulate the control.
Visible
The Boolean (true/false) value that determines whether users can see the control.
METHODS. Some objects also include special program statements calledmethods. A method brings about
some predefined action affecting the associated object. For example,show is a method that can be used
with a hidden form to make it visible.
Common methods of Visual Basic controls:
Method
Use
Move
Changes an object\u2019s position in response to a code request.
Drag

Handles the execution of a drag-and-drop operation by the user.
SetFocus Gives focus to the object specified in the method call.
ZOrder

Determines the order in which multiple objects appear onscreen.
EVENTS. Events are what happen in and around your program. For example, when a user clicks a button,

many events occur: The mouse button is pressed; the command button in your program is being clicked; and then the mouse button is released. Not all controls have the same events, but some events are shared by many controls. These events occur as a result of some specific user action. These types of events are user-initiated events and are what you will write code for most often.

Information and Communication Technology Department
Palompon Institute of Technology
2
INTRODUCING VISUAL BASIC
1
Common events of Visual Basic controls:
Events
Occurrence
Change
The user modifies text in a combo box or text box.
Click
The user clicks the primary mouse button on an object.
DblClick
The user double-clicks the primary mouse button on an object.
DragDrop
The user drags an object to another location.
DragOver
The user drags an object over another control.
GotFocus
An object receives focus.
KeyDown
The user presses a keyboard key while an object has focus.
KeyPress
The user presses and releases a keyboard key while an object has focus.
KeyUp
The user releases a keyboard key while an object has focus.
LostFocus

An object loses focus.
MouseDown The user presses any mouse button while the mouse pointer is over an object.
MouseMove The user moves the mouse pointer over an object.
MouseUp

The user releases any mouse button while the mouse pointer is over an object.
Put simply,Properties describe objects.Methods cause an object to do something.Events are what happen
when an object does something.

In Visual Basic, a program is referred to as aproject. Every Visual Basic project consists of at least two separate files \u2013 a project file (whose extension is.vbp), and a form file (with extension.frm). Some projects include multiple form files and other types of files, such as class module (.cls) files, standard module (.bas) files, resource files (.res) files, and ActiveX control (.ocx) files. Thus, the development of a Visual Basic project involves keeping track of several different files, and accessing these files individually within the Visual Basic environment, as needed.

The Visual BasicIDE (Integrated Development Environment) is a collection of menus, toolbars, and windows that make up your programming workbench. Each part of the IDE has features that affect different aspects of your programming activity. The menu bar lets you handle the overall activity and management of your programming. The toolbar enables you to access much of the menu bar's functionality through various toolbar buttons. Forms - the basic building blocks of Visual Basic programs - are presented in a Form Design window. You use the Toolbox to add controls to the forms of your project. The Project window displays the projects on which you're working, as well as the different parts of each of those projects. You browse and set a control, form, and module's properties within the Properties window. Finally, you position and view a form or forms onscreen within the Form Layout window.

Information and Communication Technology Department
Palompon Institute of Technology
3
Visual Basic Program Components
The Visual Basic IDE

Activity (19)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
fazymasthan liked this
lalitha liked this
Zohane liked this
Iordache Iasmina liked this
Tom Horrigan liked this
larimelv liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->