Visual Basic Concepts

Form Description Properties

When Visual Basic saves a form, it arranges the properties in a default ordering. However, you can list properties in any order when creating a form.

Any property you don’t list is set to its default value when loaded. When Visual Basic saves a form, it includes only those properties that do not use default values as their settings. Each control determines whether or not all of its properties are saved, or only those whose values are different from the default settings.

Syntax

Use this syntax to define properties in the form description:

property = value

Text property values must appear within double quotation marks. Boolean properties have a value of – 1 for True and 0 for False. Visual Basic interprets any value other than – 1 or 0 as True. Properties with listed values include their numeric value with the description of the value included as a comment. For example, the BorderStyle property appears like this:

BorderStyle = 0         ' None

Binary Property Values

Some controls have properties that have binary data as their values, such as the Picture property of picture box and image controls or certain properties of custom controls. Visual Basic saves all binary data for a form in a binary data file separate from the form.

Visual Basic saves the binary data file in the same directory as the form. The binary data file has the same file name as the form, but it has an .frx filename extension. Visual Basic reads the binary data file when loading the form. The binary data file (.frx) must be available to the form when Visual Basic loads it. If you share forms with others that use a binary data file, be sure to provide the binary data file (.frx) as well as the form (.frm).

Properties having binary data as their values appear in the form as a reference to a byte offset in the binary data file. For example, the value of a Picture property appears like this in a form description:

Begin VB.Image imgDemo
   Picture = "Myform.frx":02EB
End

The property listing means that the binary data that defines the Picture property of this control begins at byte 2EB (hex) in the file Myform.frx.

Icon Property

The value of the Icon property in a form depends on which icon is used for the form. The following table lists Icon property values and how those properties appear in a form.

Icon property setting ASCII form contents
The default icon No reference to the Icon property
(None)
Icon = 0
Any icon other than the default icon Byte offset reference to the binary data file. For example:
Icon = "Myform.frx":0000

TabIndex Property

If the TabIndex property is not specified, Visual Basic assigns the control the earliest possible location in the tab order once all other controls load.

Units of Measurement

Control sizes, x and y coordinates, and other property values using units of measurement are expressed in twips. When a control uses a scale mode other than twips, Visual Basic converts the twip values in the ASCII form to the units of measurement specified by the control’s ScaleMode property when loading the form.

Color Values

Color values appear as RGB values. For example, the ForeColor property appears like this:

ForeColor = &H00FF0000&

Visual Basic can also read QBColor values, converting them to RGB when loading the form. ASCII forms using QBColor values must use this syntax:

ForeColor = QBColor(qbcolor)

where qbcolor is a value from 0 to 15.

Note that the qbcolor argument corresponds to the color values used by graphics statements in other versions of Basic, such as Visual Basic for MS-DOS, Microsoft QuickBasic, and the Microsoft Basic Professional Development System.

Property Objects

Some property objects, such as the Font object, appear as a separate block, showing all of the settings for the various properties of the object. These blocks are enclosed in BeginProperty and EndProperty statements of the following form:

BeginProperty propertyname

property1 = value1

property2 = value2

EndProperty

Basic Code

The Basic code appears in the form immediately after the Attributes section following the last End statement in the form description. Statements in the Declarations section of a form appear first, followed by event procedures, general procedures, and functions.