Example - With Statement

' This sample shows some of the features of user defined types and the with

' statement

 

Type type1

a As Integer

d As Double

s As String

End Type

 

Type type2

a As String

o As type1

End Type

 

Dim type1a As type1

Dim type2a As type2

 

Sub Main ()

With type1a

.a = 65

.d = 3.14

End With

 

With type2a

.a = "Hello, world"

With .o

.s = "Goodbye"

End With

 

End With

 

type1a.s = "YES"

MsgBox type1a.a

MsgBox type1a.d

MsgBox type1a.s

MsgBox type2a.a

MsgBox type2a.o.s

End Sub