User Defined Types UDTs

User-Defined Types provide some of the power of a custom object but without the need of a class module. A class module allows the creation of custom properties and methods, whereas a UDT allows only custom properties. But sometimes, that's all you need.

A UDT is declared with a Type..End Type statement. It can be Public or Private. A name that is treated like an object is given to the UDT. Within the Type, individual variables are declared that become the properties of the UDT.

Within an actual procedure, a variable is defined of the custom type. When that variable is used, the properties are available, just as they are in a custom object (see Figure 20.14).

The following example uses two UDTs to summarize a report of product styles in various stores.

0 0

Post a comment