View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_3_] Bob Phillips[_3_] is offline
external usenet poster
 
Posts: 2,420
Default Private vs Public Class Modules

Ronald,

I am not getting this. I have just created a class and a collection class,
and setup multiple instances of the first. My collection class variable was
a public variable.

In another module, I accessed this public collection class variable no
problems.

I guess I am not getting the problem?

--
__________________________________
HTH

Bob

"Ronald R. Dodge, Jr." wrote in message
...
If you notice in the example that I stated, the TempEmployees is the
collection class while the TempEmployee is the Individual object class
similar to the Worksheets collection class with the Worksheet individual
object class.

The TempEmployees collection class is a holder for all of the individual
TempEmployee object classes (One per temporary employee). As such, there
only needs to be one TempEmployees collection object in memory vs several
TempEmployee individual objects in memory.

The problem I'm having, I want to expose this TempEmployees Object to be
visible across the entire project, not just within the module. As it
currently stands, I can only think of using either properties or methods
to set that, which seems to be a lot of work (when you have to do it
across several different classes) that would save some time and prevent
possible overlooking if it could just be set to a variable that could be
seen across the project (I.e. Within VB6, you use the Friend keyword which
allows such cases to be seen outside of the module the code in it, but not
outside of the project the code is in.)

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"Bob Phillips" wrote in message
...
Ronald,

If you want multiple instances of a class, why not create a collection
class? It does mean that you have to code the .Add and .Remove methods,
but it is not difficult.

--
__________________________________
HTH

Bob

"Ronald R. Dodge, Jr." wrote in message
...
VB6.0
Excel 2002, SP3

How can I get private and public instancing class modules to communicate
with each other?

Example

I am creating a program that using a class name of "TempEmployee" (Need
multiple instances of this class, thus private instance is the only
instance available) and a collection class name of "TempEmployees" (This
object, only need one instance of it and I would like to be able to
reference to it from within any other module within the project, but
when I attempt to set a public variable to it, it comes back stated
can't do it as a public variable can't contain a private class module).
I also get the same basic issue with I attempt to combine public and
private classes into each other. What is the best way to resolve this
issue so as I don't have to do so much coding and work arounds?

One way, I could create properties in so many other objects as a
reference to this one object, on the other hand, that in itself seems to
be a lot of work and could lead to possible overlooking. What is a good
book on this sort of VBA Class module coding?

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000