Results 1 to 6 of 6

Thread: (Resolved) - Class within a Class

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Albany, NY
    Posts
    489

    (Resolved) - Class within a Class

    We have created class modules and collections for
    a project.

    One Class is Called Project, it has several properties:
    Customer, CustomerPhone#......

    Each Project can have a Quality Assurance(class) which also
    has it's own properties: Statement_of_Work, Batch_process....

    The problem is that I want to access the Quality Assurance
    Class from my Project Class Like So:

    Dim MyProj as New Project
    MyProj.QualityAssurance.Statement_of_work = "something"
    ---------this give me an error of Object not Set ------------


    I can create New Projects and New Quality Assurances but
    I cannot access them the way I stated above.

    I am guessing that I have to link them somehow but I'm
    not sure what to do.

    Basically I just want to have a class within a class.
    Any help is appreciated!!!
    Last edited by jcfowl; Mar 13th, 2002 at 10:03 AM.

  2. #2
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479
    The parent class needs interfaces to the child class properties.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Albany, NY
    Posts
    489

    Thanks for the Response

    Could you be more specific. Do I need to place some
    code inside the Initialize() statement of the Parent?
    How do I set up the interfaces to the Child?

  4. #4
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479
    However the child class initialises or sets a property the parent class needs to access this.
    So if you want to set values of a child class on the initialisation of the parent class call the child classes properties from the parent class initialise method.

    Heres a bad example.
    If you have a class BOX and a class BIGBOX
    BIGBOX contains 2 BOXs
    A BOX has 1 variable mySize
    So BOX has a property SIZE thats set its mySize.
    If you initialise a BIGBOX you need to call the SIZE property of each of its BOXs to set them.
    So the outside interface to each BOX is through a BIGBOX.

    I can't believe I wrote that double dutch crap.
    Can somebody else explain better please?

  5. #5
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    In class cProject:

    Code:
    Public Property Get QualityAssurance() As cQualityAssurance
    
    Dim qaThis As New cQualityAssurance
    'set qathis properties for this project..projectid?
    Set QualityAssurance = qaThis
    
    End property
    Hope this helps,
    Duncan
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Albany, NY
    Posts
    489
    Great!

    Thanks for the help.

    I had the basic Idea but didn't really know how to do it.
    with your examples i figured it out. Thanks a lot.

    jcfowl

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