Results 1 to 5 of 5

Thread: [RESOLVED] Setting a class as a property

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2003
    Posts
    28

    Resolved [RESOLVED] Setting a class as a property

    Hi
    I am trying to set a class as a property of another class.
    I have one class clsCompany and another clsPerson
    I am trying to set clsPerson as a property of clsCompany and as an array.
    Elsewhere in clsCompany I am setting the number of of 'clsPerson' instances (PersonCount) and creating a local array of Person instances (moPerson).
    I then try and return the clsPerson as follows in my code

    Code:
    For intCnt = 1 To oCompany.PersonCount
      Debug.print oCompany.Person(intCnt).Surname
    Next
    Code:
    Public Property Get Person(ByVal iI As Integer) As clsPerson
      Set Person(iI) = New clsPerson   'Problem with this line
      iI = iI - 1                                                      
      If iI >= 0 And iI <= UBound(moPerson) Then        
          Set Person(iI) = moPerson(iI)                       
      End If
        
    End Property
    As soon as it gets to 'Set Person(iI) = New clsPerson' it just loops through from 'Public Property Get Person...'

    How can I best achieve what I am trying to do?

    Many thanks in advance.
    Last edited by bobjbarker; Apr 12th, 2011 at 02:13 AM.

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