User-Defined Types

A collection of related variables can be grouped together under one name. The TYPE statement defines the elements of a user-defined type.

Type measurement

julianday As Integer

level As Double

End Type

 

The TYPE definitions must appear at the top of a script file, before any subroutines. The TYPE…END TYPE statement defines a new type; it does not create a variable of that type. Variables of the user-defined type must be declared in a Dim statement. The elements of a user-defined type variable are accessed by using the variable name followed by a period and the element name:

Dim m As measurement

m.julianday = 192

m.level = 12.3

Debug.Print m.julianday ' prints 192 in the Immediate window

Debug.Print m.level ' prints 12.3 in the Immediate window

See Also

Variables

Object Variables

Array Variables

Global Variables

Coordinate Arrays

Scripter BASIC Language

Object Hierarchy

Object List