|
-
Jul 4th, 2004, 10:39 PM
#1
Thread Starter
Addicted Member
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
-
Jul 5th, 2004, 03:53 AM
#2
Sleep mode
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 .
-
Jul 5th, 2004, 04:17 AM
#3
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.
-
Jul 5th, 2004, 04:28 AM
#4
VB Code:
public Class A
....
end Class
public Class B
private [b]Shared[/b] MyA as new A
.......
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|