|
-
Jan 5th, 2002, 04:19 PM
#1
Thread Starter
Addicted Member
I thought they were global
I have a sub that defines a new collection. I then attempt to add an item to it within a function and it craps out complaining about the object not being defined. I thought that once an object was defined it was accessable to everything.
Any ideas what's wrong?
Everso
-
Jan 5th, 2002, 04:37 PM
#2
Frenzied Member
It depends upon how you define it. The only way to make a variable (object or otherwise) avaialble to everything in your program is to use the Public key word in a module.
VB Code:
'In a module
'Available to everything
Public MyCollection As Collection
'Available to everything in this module
'But not other forms or modules
Private MyCollection As Collection
{EDIT} It must be defined in the declarations section of the module. Defining it in a sub or function in a mdoule does not work.
Greg
Last edited by gdebacker; Jan 5th, 2002 at 04:40 PM.
Free VB Add-In - The Reference Librarian
Click Here for screen shot and download link.
-
Jan 5th, 2002, 04:38 PM
#3
Frenzied Member
You can create an object in a sub and then pass a reference to a function in another module without the object being public.
Greg
Free VB Add-In - The Reference Librarian
Click Here for screen shot and download link.
-
Jan 5th, 2002, 05:15 PM
#4
Thread Starter
Addicted Member
Thanks. I'll go have a play. I was hoping to avoid a module because it allways seems silly having a module with only a declaration in it 
Everso
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
|