+ Reply to Thread
Results 1 to 3 of 3

Classes containing Classes

Hybrid View

  1. #1
    Adam
    Guest

    Classes containing Classes

    I have the following set up:

    'Class Person
    Private myPrivate as PrivateInfo
    .....

    Private Sub Class_Initialize()
    Set myPrivate = new PrivateInfo
    ...
    End Sub
    ....
    Property Get getPrivate() as PrivateInfo
    getPrivate = myPrivate
    End Property
    ....

    'End Class Person

    where PrivateInfo is a different class module.

    Then I have a userform that has a sub called setInfo that takes a
    PrivateInfo as a parameter. Is there a way that I can call something
    similar to this:

    Private joe as Person

    PrivateInfoUserform.setInfo joe.getPrivate()

    I have code similar to that above but it gives me an "Object variable
    or With block variable not set (Error 91)" error. What am I doing
    wrong?


  2. #2
    Chip Pearson
    Guest

    Re: Classes containing Classes


    Adam,

    > Property Get getPrivate() as PrivateInfo
    > getPrivate = myPrivate
    > End Property


    should be

    Property Get getPrivate() as PrivateInfo
    SET getPrivate = myPrivate
    End Property


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com



    "Adam" <Adam.Herrmann@gmail.com> wrote in message
    news:1143845651.529358.33910@j33g2000cwa.googlegroups.com...
    >I have the following set up:
    >
    > 'Class Person
    > Private myPrivate as PrivateInfo
    > ....
    >
    > Private Sub Class_Initialize()
    > Set myPrivate = new PrivateInfo
    > ...
    > End Sub
    > ...
    > Property Get getPrivate() as PrivateInfo
    > getPrivate = myPrivate
    > End Property
    > ...
    >
    > 'End Class Person
    >
    > where PrivateInfo is a different class module.
    >
    > Then I have a userform that has a sub called setInfo that takes
    > a
    > PrivateInfo as a parameter. Is there a way that I can call
    > something
    > similar to this:
    >
    > Private joe as Person
    >
    > PrivateInfoUserform.setInfo joe.getPrivate()
    >
    > I have code similar to that above but it gives me an "Object
    > variable
    > or With block variable not set (Error 91)" error. What am I
    > doing
    > wrong?
    >




  3. #3
    Adam
    Guest

    Re: Classes containing Classes

    Thank you very much that worked perfectly.


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1