Results 1 to 4 of 4

Thread: How to, need help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    BC, Canada
    Posts
    142

    How to, need help

    I have two class:

    public Class A
    ....
    end Class

    public Class B
    private MyA as new A ''not sure how to code this line
    .......
    end Class

    I want Class A be a member of Class B, but I like Class B remains its status/value after class A is out of scope. To put it the other way, I would like several instances of Class B to share one instance of class A. Is it possible?

    Thanks

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Winla

    I want Class A be a member of Class B, but I like Class B remains its status/value after class A is out of scope.
    Basically , classes are referenced types . So , when the class is out of scope the pointer to that class goes out of scope too .

  3. #3
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    If you will only ever have 1 instance of A, then you could just create a global instance of the object in a module/form. Then just reference it when required, of course this all depends on what you want to do with it, theres loads of different ways you can use classes and references.

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    VB Code:
    1. public Class A
    2. ....
    3. end Class
    4.  
    5. public Class B
    6. private [b]Shared[/b] MyA as new A
    7. .......
    8. end Class

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