|
-
Feb 7th, 2001, 12:43 PM
#1
Thread Starter
Hyperactive Member
I've done this before but i can't remember how to do it....
How do you create sub properties of a property in a class?
If i have a Class titled "Person", and a property titled "Hand", how do i create a sub property of "Hand" called "Left" and/or "Right"?
Thanks for any help.
Bababooey
Tatatoothy
Mamamonkey
-
Feb 7th, 2001, 11:49 PM
#2
Hyperactive Member
Make the hand property a class itself, and give it an enum property for left and right. Something like...
Code:
'/
'/ CHand:
'/
Private m_h as enumHandedness
'/
Public Enum enumHandedness
Righty =0
Lefty
End enum
'/
Public Property Get Handedness() as enumHandedness
Handedness= m_h
End Property
Public Property Let Handedness(byval RHS as enumHandedness)
if RHS < enumHandedness.Righty or RHS > enumHandedness.Lefty Then RHS = enumHandedness.Righty '/ remember enum's are not enforced, so have a default ;-)
m_h = RHS
End Property
'/
'/ CPerson
'/
Private m_H
'/
Public Property Get Hand() as CHand
If m_H Is Nothing Then Set m_H = New CHand
Set Hand = m_H
End Property
Then whenever you use it you get...
Code:
Dim oPerson as CPerson
Set oPerson = New CPerson
oPerson.Hand.Handedness = Righty
I know that hand.handedness doesn't make logical sense, but you get the idea.
td.
"One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig
[email protected]
"but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.
-
Feb 8th, 2001, 07:10 AM
#3
Thread Starter
Hyperactive Member
Bababooey
Tatatoothy
Mamamonkey
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|