BobBridges
Active Member
I'm getting into user forms in Excel for the first time, and I'm puzzled by the way it behaves in one regard.
I've created a form that I named RoMOpts. I don't usually name the object variable the same as the class name, but in this case I did: In the main module I declared an variable named RoMOpts as Public, then set RoMOpts = New RoMOpts. Inside the RoMOpts module I refer to its controls as chkVest, radSts and so on; in other modules it's necessary to qualify the references: RoMOpts.chkVest, RoMOpts.radSts and so on.
So far, so good. But the scope of Public RoMOpts apparently doesn't extend to the code in another class module. When I invoke a method of that class and try to watch the values of RoMOpts, I'm told that the object hasn't yet been set. Then when the code first refers to RoMOpts.radSts, the Watch window is suddenly aware of RoMOpts—but all its values are the defaults, not the current values as set by the operator (me, I mean). I get the impression that it's watching a different object, not the one I declared Public.
Aren't Public variables available to other class modules? Sure, they are. But not this one. Is it because I've named the object the same as the class, or are user forms different in this regard, or what? Anyone know?
I've created a form that I named RoMOpts. I don't usually name the object variable the same as the class name, but in this case I did: In the main module I declared an variable named RoMOpts as Public, then set RoMOpts = New RoMOpts. Inside the RoMOpts module I refer to its controls as chkVest, radSts and so on; in other modules it's necessary to qualify the references: RoMOpts.chkVest, RoMOpts.radSts and so on.
So far, so good. But the scope of Public RoMOpts apparently doesn't extend to the code in another class module. When I invoke a method of that class and try to watch the values of RoMOpts, I'm told that the object hasn't yet been set. Then when the code first refers to RoMOpts.radSts, the Watch window is suddenly aware of RoMOpts—but all its values are the defaults, not the current values as set by the operator (me, I mean). I get the impression that it's watching a different object, not the one I declared Public.
Aren't Public variables available to other class modules? Sure, they are. But not this one. Is it because I've named the object the same as the class, or are user forms different in this regard, or what? Anyone know?