Visual Basic Project Files: .VBP file: Project File: a

Download Report

Transcript Visual Basic Project Files: .VBP file: Project File: a

Visual Basic Project Files:
.VBP file: Project File: a small text file that contains
the names of other files in the project, as well as
some information about the VB environment
(release 2.0 and 3.0 of VB, .MAK extensions for
project files)
.FRM file: Form File: each form in the project is
saved in a .FRM extension. Each form file holds a
description of all Objects and their Properties for the
form, as well as the Basic Code written
(In VB each of these Form Files is referred to as a
Form Module)
.BAS file: Standard Code Modules: hold VB ‘Basic’
statements that can be accessed from any Form
.BAS files are used in multiform projects
.OCX file: Custom Controls: additional
controls/custom controls are stored in .OCX files. If
projects include controls that are not part of the
Standard Control Set, then .OCX file names will be
included in the project
(All controls have .OCX extensions, however, this is
implicit in controls internal to the VB Environment,
and these extensions are not visible to the user)
.VBW file: after the project is saved, VB automatically
adds one more file to the project, which holds
information about each of the project Forms
Project Tip
Create a New Folder for a project, before creating any
files for the project
Save the .VBP file
Save the .FRM files, and
Save the .BAS files into the folder
Then if the project needs to be copied or transferred
from the ‘C: Drive’ to the ‘A: Drive’, all of the project
files can be transferred together within the folder, and
no component parts (.VBP, .FRM, .OCX[if existing])of
the project will be lost
Component parts of a project can be lost and always
save each component part separately
Design Time, Run Time, Break Time
VB has 3 distinct modes:
Design Time: relates to designing the ‘UserInterface’ and writing code
Run Time: relates to testing and running the project
Break Time: if there is a ‘run-time error’ or project
execution is paused
Project Tips
Do not confuse the ‘Name’ and ‘Caption’ properties
‘Name’ refers to the control in the VB code
‘Caption’ refers to the users view on the form
VB sets both of these properties to the same value by
default, and therefore it is easy to confuse them
NB: Always set the ‘Name’ property of controls before
writing code
If the ‘Name’ of an object is changed after the code has
been written, then the code becomes separated from the
object and the program does not run properly
VB Project Example
The first ‘Event-Driven’ project will
create a form with 3 controls
It will display the message ‘Hello
world’ when the user clicks the ‘Push
Me’ command button, and will
terminate when the user clicks the
‘Exit’ command button
(Tip: If the Project Explorer
Window/Properties Window/Toolbox are not
displayed, open the View menu and select
Project Explorer Window/Properties Window/
Toolbox
When a VB project is running, the user can do many
things
Each action by the user causes an ‘Event’ to occur in
the VB project
If you write VB code for a particular event, the VB will
respond to the event and automatically execute your
procedure (eg: clicking on a command button)
VB ignores events for which no procedures are
written
(eg: moving the mouse
resizing a window
opening another application)
VB code written in procedures
We deal with writing code in ‘Sub Procedures’ or ‘Sub
Programs’
Begins with: Private Sub
Ends with: End Sub
VB automatically names the event proceudres
The ‘Name’ consists of the object name, an underscore
( _ ), and the name of the event
(name of the command button is cmdPush and there
is a Click event for the command button
Therefore, the name of the Sub Procedure:
cmdPush_Click
The Form Window is where the forms are designed
that make up the User-Interface
Always create a ‘User-Friendly’ User-Interface
Standard windows techniques can be used to
change the size and location of the form
‘Mouse-Driven Environment’
By default, a new form created in a new project, is
called Form1, when the file is saved, the programmer
assigns a more meaningful name to the file
(?: What is the extension?)
The Project Explorer Window holds the filenames
of the files included in the project
The windows Title Bar holds the name of the project,
which is Project1 by default, until saved and given a
more meaningful name
(?: What is the extension?)
The Properties Window, its use relates to setting the
properties for the objects in the project
Check Box 1/0, True/False
Option Box 1/0, True/False
Command Button ‘Name’ how the computer
recognises/identifies the control/object
‘Caption’ relates to the user identification of the
control/object
Text Box ‘Text’ property: ‘Blank’
‘Name’ property: like command button
Form Window State ‘Maximise’, relates to
maximising the form when the project is executed
The Form Layout Window, this indicates the
position of the form on the desktop, when the
execution of the project begins
The Toolbox holds the tools that are used to place
controls on the form
The tools displayed on the toolbox, may be different,
depending on the edition and release of VB being
used
‘Professional Edition’
The Main Visual Basic Window holds the VB menu
bar, the toolbar, and the form location and size
information
The Toolbar, the buttons on the toolbar can be used
as shortcuts for frequently used operations
Each button represents a command that can be
executed by clicking on the button or by choosing a
command from the menu bar
The Form Location and Size Information identifies
the size and position of the form on the screen
Help VB has an extensive ‘Help’ facility
VB contains what is called ‘Context-Sensitive’ help