Syntax 

[ | Private | Public ] _

Type name

    elem [([dimension[, ...]])] As [New] type

    [...]

End Type


Group 

Declaration 


Description 

Define a new user type. 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.


Access 

Macros: Public is assumed if access is omitted.


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