< Day Day Up > |
All types except for modules may be declared within another type. A type defined within another type is called a nested type . To refer to a nested type from outside the type it is declared in, you must qualify the type name with the outer type's name . Class Customer Class FullAddress Public Street As String Public City As String Public State As String Public ZIP As Integer End Class Public Name As String Public Address As FullAddress End Class In this example, the address of a customer is stored in a FullAddress type that is declared within the Customer type. It could be used in the following way. Dim Address As Customer.FullAddress Dim Customer As Customer Address = New Customer.FullAddress() Address.Street = "134 Main Street" Address.City = "Tulsa" Address.State = "OK" Address.ZIP = 19348 Customer = New Customer() Customer.Name = "John Doe" Customer.Address = Address Nested types are most commonly used for helper types that are used only within a type.
|
< Day Day Up > |