Multi-level User Definet Types

S

steve

Can you create a UDT with multiple levels of depth?

For example, if I had user defined type called house with the sublevels
shown below, would I be able to dim House1 as house and have a multi-layered
UDT so that I could call values like this House.MasterBedroom.Height or
House.DiningRoom.Breadth?

I'm not sure if this explains what I'm asking, but it's the best example I
can think of. Below is the structure for the UDT that I am imagining. Is it
possible to have a UDT that is more than one layer deep, with elements and
sub-elements?

House
->MasterBedroom
--->Breadth
--->Depth
--->Height
--->Flooring
--->PaintColour
->Guestroom
--->Breadth
--->Depth
--->Height
--->Flooring
--->PaintColour
->LivingRoom
--->Breadth
--->Depth
--->Height
--->Flooring
--->PaintColour
->DiningRoom
--->Breadth
--->Depth
--->Height
--->Flooring
--->PaintColour
->Bathroom
--->Breadth
--->Depth
--->Height
--->Flooring
--->PaintColour
 
R

Rick Rothstein \(MVP - VB\)

You would use two UDTs... one for the room type and another for the
properties; then you would declare the individual room types to be of the
properties type. Here is an example...

Private Type Properties
Breadth As Double
Depth As Double
Height As Double
Flooring As Long
PaintColour As Long
End Type

Private Type Rooms
MasterBedroom As Properties
Guestroom As Properties
LivingRoom As Properties
DiningRoom As Properties
Bathroom As Properties
End Type

You can now declare a variable to be of type Rooms and it will automatically
possess the properties. For example,

Dim MyRooms As Rooms
MyRooms.Livingroom.Height = 8.25

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top