Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
TYPE Statement Details
◄Summary► ◄Details► ◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
TYPE usertype
elementname AS typename
[elementname AS typename]
.
.
.
END TYPE
Usage Notes
■ If the argument usertype is a table type, any elementname arguments are
the names of columns in the table. The names must be exact matches to
existing column names and must follow the ISAM naming conventions.
See: ◄ISAM naming conventions►
■ The typename can be a user-defined data type, a nested user-defined
type (data types only), or an array.
■ Visual Basic now supports:
• Currency data type for dollars and cents math
• Static arrays in user-defined types
• User-defined types for ISAM tables
■ Before you can use an ISAM table, you must declare a record type
for the records that make up the table. Instances of this type
are used to pass records to and from the table.
■ The following TYPE statement illustrates the use of static arrays. The
record StateData includes the CityCode static array, and the record
Washington has the same structure as StateData:
TYPE StateData
CityCode (1 TO 100) AS INTEGER 'Declares a static array
County AS STRING * 30
END TYPE
DIM Washington(1 TO 100) AS StateData
■ When you declare a static array within a user-defined type, its
dimensions must be declared with numeric constants rather than
variables.
■ For efficiency, make sure that arrays within a user-defined type
start on even offsets.
■ You can create very large records when you include static arrays
within records. Putting one of these records within a SUB procedure
can use large amounts of stack space.
■ Strings in user types must be fixed-length strings. String lengths
are indicated by an asterisk and a numeric constant. For example,
the following code defines an element named Keyword in a user-defined
type as a string with length 40:
TYPE
Keyword AS STRING * 40
END TYPE
■ A user-defined type must be declared in a TYPE declaration before it can
be used in the program. Although a user-defined type can be declared in
the module-level code, you can declare a variable to be of a user-
defined type anywhere in the module, even in a SUB or FUNCTION.
■ Use the DIM, REDIM, COMMON, STATIC, or SHARED statements to declare a
variable as a user-defined type.
See: ◄DIM Statement► ◄REDIM Statement► ◄COMMON Statement►
◄STATIC Statement► ◄SHARED Statement►
■ The keyword REM cannot be used as a field name in a TYPE statement.
The text that follows is treated as a comment. See: ◄REM Statement►
■ If you have defined a table to have columns A, B, C, and D, you can use
a user-defined type that has only the columns you need (any subset of A,
B, C, and D).