Projects
The end result of most VB programming efforts is an executable program (one
that has a .EXE extension). This file is compiled from the actual text
files which make up a VB project. VB doesn't put the entire project into a
single file. Instead, it allows the programmer to break up a project into
several smaller files. Each of these files can be used in more than one
VB project. The group of files used to compile the application is called
a VB project and is the topic for discussion in this section of the tutorial.
Project Definition
A typical VB application might consist of more than one forms, each of which
may have multiple controls. In VB, the information about each form (it's own
properties as well as those of the controls that are on the form) is saved
into it's own file. In fact, there are several types of files which VB
creates (we'll cover them all later in the tutorial).
VB also saves a "project" file which contains the list of files which VB
loads when the "project" is loaded. The project file includes other
information, such as the filenames of controls which are not intrinsic to VB
(they exist as separate files with .OCX extensions).
The project file is a simple ASCII text file and may be edited with any
text editor, including NOTEPAD (which comes with Windows). Once you learn
the format of the project file you may have reason to edit it directly but
in general, most programmers do their editing within the VB IDE.
The project file is saved with an extension of .VBP (Visual Basic Project).
Other files saved by VB include the following extensions:
- .FRX : graphics associated with the form
- .BAS : code not associated with control events
The good thing about splitting a project into many files is that you can
use a file (form or otherwise) in one or more projects. If you make a
change to the one file, all using projects see the change.
In the following VB IDE example, you see a project with two forms, each
with multiple controls. The filename of each form is displayed in the
project window, as is the name of a single .BAS file. Together, all three
files make up the VB project.
(click to enlarge)
Here is the content for each of the files. You will note that the files
are in ASCII text. By inspection, you can guess what a lot of the line items
are for.
- Project File
Type=Exe
Form=2ndForm.frm
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\WINDOWS\SYSTEM\STDOLE2.TLB#OLE Automation
Form=testform.frm
Startup="Form1"
Command32=""
Name="Project1"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="Personal"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1
- Form 1
VERSION 5.00
Begin VB.Form Form1
Caption = "2ndForm"
ClientHeight = 2280
ClientLeft = 5805
ClientTop = 2055
ClientWidth = 3735
LinkTopic = "Form1"
ScaleHeight = 2280
ScaleWidth = 3735
Begin VB.CheckBox Check2
Caption = "Check2"
Height = 495
Left = 2160
TabIndex = 3
Top = 360
Width = 1215
End
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 495
Left = 240
TabIndex = 2
Top = 360
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "Command2"
Height = 495
Left = 2160
TabIndex = 1
Top = 1320
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 360
TabIndex = 0
Top = 1320
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
- Form 2
VERSION 5.00
Begin VB.Form Form2
Caption = "Form2"
ClientHeight = 1905
ClientLeft = 6600
ClientTop = 2025
ClientWidth = 3465
LinkTopic = "Form2"
ScaleHeight = 1905
ScaleWidth = 3465
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Left = 2040
TabIndex = 2
Top = 1320
Width = 1095
End
Begin VB.TextBox Text2
Height = 285
Left = 1080
TabIndex = 1
Text = "Text2"
Top = 720
Width = 1695
End
Begin VB.TextBox Text1
Height = 285
Left = 1080
TabIndex = 0
Text = "Text1"
Top = 240
Width = 1695
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
As you go through more of the tutorial, the content of the files will make
more sense, but even now you can see that the information is not that
difficult to decipher.
|