Click to See Complete Forum and Search --> : Visual Basic


Atul
October 11th, 1999, 10:22 AM
Why a class module cannot have a static variable as a data member ? Should it not work in a similar way as a static member declared in a c++ class ?

AtulK

Lothar Haensler
October 11th, 1999, 10:30 AM
the documentation says "Static is unnecessary at module level, since all module-levelvariables are static. "
Well, you can't have a Static variable outside a function or sub. That's even true with non-class modules (so called standard modules).
Even if it "should...work in a similar way...", it doesn't.

Atul
October 11th, 1999, 10:59 AM
Dear Lothar,
I have already tried the declarion of Static members in a class module which does not work. I thank you for your advice/suggession any way.
I also thought of the same thing. But further the problem is that, if I don't have provision of declaring static members in a class, I cannot implement something like keeping track of instances of my class. Thanx for replying !

AtulK

Lothar Haensler
October 11th, 1999, 11:02 AM
>I cannot implement something like keeping track of instances of my class.

This is not true.
By creating an ActiveX exe and specifying SingleUse as instancing property of your public class modules you can quite well keep track of instances of your class.
Simply use a Class-global variable.

Atul
October 11th, 1999, 11:07 AM
Yeh !! You are right man !!
Still, I have to switch to from standard.exe project for that. ( I simply love this coversation !!!)

AtulK