Results 1 to 3 of 3

Thread: sub properties

  1. #1

    Thread Starter
    Hyperactive Member noble's Avatar
    Join Date
    Nov 2000
    Location
    Philly
    Posts
    471
    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

  2. #2
    Hyperactive Member tumblingdown's Avatar
    Join Date
    Mar 2000
    Posts
    362
    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.

  3. #3

    Thread Starter
    Hyperactive Member noble's Avatar
    Join Date
    Nov 2000
    Location
    Philly
    Posts
    471
    ty, now i remember :P
    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
  •  



Click Here to Expand Forum to Full Width