User Defined Types

 

Users can define their own types that are composites of other built-in or user defined types.  Variables of these new composite types can be declared and then member variables of the new type can be accessed using dot notation.  Only variables of user defined types that contain simple data types can be passed to DLL functions expecting ‘C’ structures.

 

User Defined types are created using the type statement, which must be placed outside the procedure in your Enable Code.  User defined types are global.  The variables that are declared as user defined types can be either  global or local. User Defined Types in Enable cannot contain arrays at this time                

 

Type type1

    a As Integer

    d As Double

    s As String

End Type

 

Type type2

    a As Integer

    o As type1

End Type

 

Dim type2a As type2

Dim type1a As type1

 

Sub TypeExample ()

    a = 5

    type1a.a = 7472

    type1a.d = 23.1415

    type1a.s = "YES"

    type2a.a = 43

    type2a.o.s = "Hello There"

    MsgBox type1a.a

    MsgBox type1a.d

    MsgBox type1a.s

    MsgBox type2a.a

    MsgBox type2a.o.s

    MsgBox a

End Sub