If you know how Form objects are stored, you
will be able to move them from one project to
another or from one version of VB to another.
After a form has been designed and saved,
the information from the form is separated into
two components. The first component is a text
description of the form itself—all objects
contained on the form, all object properties
and their values, as well as any code associated
with the form and the objects. This text-based
information is stored in an ASCII text file
with the extension .FRM. Figure 4.21 shows a
sample of a text-based .FRM file. Any word processor
or text editor can open this file.
FIGURE 4.21 Sample .FRM file containing
the form information.
The second file is .FRX. It contains all graphics-related
information required by the form. If a Picture
control or Image control is used, and a bitmap
graphic is referenced by the control, that image
must be stored internally. This information
is stored in the separate .FRX file and is in
a binary format. The .FRM file will contain
references to the .FRX file and a number indicating
the image to be referenced for specific controls.
Knowing how the form objects are stored after
designing them can be very useful. If a form
is taken to another project and doesn't
seem to load properly, you could open the text
file and determine whether that form uses paths
for files that are not the same in the new environment.
Often as forms are moved between projects,
the references to various controls are not always
the same. You can use a text editor to open
the file and verify the references that should
be included within that project.
Another reason that you may need to look at
the form's text file would be that of
an old form from a previous version of Visual
Basic being used within a newer version. By
opening the text file with an editor, any problem
lines can be removed.
The same technique is probably even more useful
when taking Form objects from a newer version
of VB and going to an older version of the software.
This section has covered how forms are brought into memory and removed from
memory. If you need to display a form, use the Show method. Use the Hide method
to make a form invisible. The storage of the design-time form is separated into
a text-description file with the extension .FRM. Graphics information is stored
in an .FRX file. Both files together implement the form.
Creating Data Input Forms and Dialog Boxes topics