Type Definition

Syntax

[ | Private | Public ] _
Type name
elem
[([dim[, ...]])] As [New] type
[...]
End
Type

Group

Declaration

Description

Define a new usertype. Each elem defines an element of the type for storing data. As [New] type defines the type of data that can be stored. A user defined type variable has a value for each elem. Use .elem to access individual element values.

Type defaults to Public if neither Private or Public is specified.

Example

Type Employee
FirstName As String
LastName As String
Title As String
Salary As Double
End
Type

Sub
Main
Dim
e As Employee
e.FirstName = "John"
e.LastName = "Doe"
e.Title = "President"
e.Salary = 100000
Debug
.Print e.FirstName '"John"
Debug
.Print e.LastName '"Doe"
Debug
.Print e.Title '"President"
Debug
.Print e.Salary ' 100000
End
Sub