Referencing a UserControl inside a Module
Author |
Message |
Andrew Raasta #1 / 7
|
 Referencing a UserControl inside a Module
Hey all, This may be a dumb question..... What is the method to reference an ActiveX Control from inside a Module (or Class Module)? If I only declare the UC I get <Object or Variable not set>, but if I try to then instantiate the UC, it does not show in the IntelliSense list and I get "Not Defined" error. I need to use a UC, I need to use a Module, and I need to change the value of an object within the UC from within the Module. Could use a pointer here. All help is greatly appreciated! -- Andrew
|
Sat, 18 Sep 2004 05:40:48 GMT |
|
 |
Andrew Raasta #2 / 7
|
 Referencing a UserControl inside a Module
Had my question answered. Nevermind on this one... -- Andrew
Quote: > Hey all, > This may be a dumb question..... > What is the method to reference an ActiveX Control from inside a Module (or > Class Module)? If I only declare the UC I get <Object or Variable not set>, > but if I try to then instantiate the UC, it does not show in the > IntelliSense list and I get "Not Defined" error. > I need to use a UC, I need to use a Module, and I need to change the value > of an object within the UC from within the Module. Could use a pointer > here. All help is greatly appreciated! > -- Andrew
|
Sat, 18 Sep 2004 06:45:28 GMT |
|
 |
Umesh Balan #3 / 7
|
 Referencing a UserControl inside a Module
Hey, same problem with me.. can u help please .
Quote: > Hey all, > This may be a dumb question..... > What is the method to reference an ActiveX Control from inside a Module (or > Class Module)? If I only declare the UC I get <Object or Variable not set>, > but if I try to then instantiate the UC, it does not show in the > IntelliSense list and I get "Not Defined" error. > I need to use a UC, I need to use a Module, and I need to change the value > of an object within the UC from within the Module. Could use a pointer > here. All help is greatly appreciated! > -- Andrew
|
Sat, 18 Sep 2004 21:39:21 GMT |
|
 |
Andrew Raasta #4 / 7
|
 Referencing a UserControl inside a Module
This is the answer I received and it worked like a champ: In the module: Private UC as [Name of the usercontrol] In the Usercontrol_Initialize(): Set UC = Me So you can reference the Usercontrol. -- Andrew
Quote: > Hey, > same problem with me.. > can u help please .
> > Hey all, > > This may be a dumb question..... > > What is the method to reference an ActiveX Control from inside a Module > (or > > Class Module)? If I only declare the UC I get <Object or Variable not > set>, > > but if I try to then instantiate the UC, it does not show in the > > IntelliSense list and I get "Not Defined" error. > > I need to use a UC, I need to use a Module, and I need to change the value > > of an object within the UC from within the Module. Could use a pointer > > here. All help is greatly appreciated! > > -- Andrew
|
Sun, 19 Sep 2004 00:23:21 GMT |
|
 |
Umesh Balan #5 / 7
|
 Referencing a UserControl inside a Module
Hey Thanx, but my problem is somewhat different. See I have created an Active X EXE in VB. Now it has various child forms in it. All of these child forms have certain custom built OCX's in them. All of these custom built OCX have a public exposed methods Enable and Disable. Example. We have 2 OCX. ocxA (On Child from frmA) ocxB (On Child from frmB) From the main from to disable the OCX A I will write. frmA.ocxA.Disable It works great. NOW MY PROBLEM How do I call the disable method of ocxA from inside ocxB(not frmB) I assume I wil have to get the pointer to the current running instance of ocxA in memory. I tried something like this inside ocxB code. Dim objA as Object Set objA = GetObject(ocxA.SomeClassID) This does not work. Help me out man. Reagrds Umesh Balani
Quote: > This is the answer I received and it worked like a champ: > In the module: > Private UC as [Name of the usercontrol] > In the Usercontrol_Initialize(): > Set UC = Me > So you can reference the Usercontrol. > -- Andrew
> > Hey, > > same problem with me.. > > can u help please .
> > > Hey all, > > > This may be a dumb question..... > > > What is the method to reference an ActiveX Control from inside a Module > > (or > > > Class Module)? If I only declare the UC I get <Object or Variable not > > set>, > > > but if I try to then instantiate the UC, it does not show in the > > > IntelliSense list and I get "Not Defined" error. > > > I need to use a UC, I need to use a Module, and I need to change the > value > > > of an object within the UC from within the Module. Could use a pointer > > > here. All help is greatly appreciated! > > > -- Andrew
|
Sun, 19 Sep 2004 13:14:14 GMT |
|
 |
Andre #6 / 7
|
 Referencing a UserControl inside a Module
Umesh, Well hmmmm.... I am not by any stretch of the imagination an ocx guru.....yet. And I have not yet tried creating an ActiveX EXE app, or used two custom ocx's at the same time, but to me at this point it really doesn't sound like that makes a difference. The way I understand controls, is that from outside the control, other objects only have access to the properties, methods and events exposed as public by that control. Just so I am on the same page with you, I take by your stating Disable you are not trying to do ControlA.Enable = False from inside ControlB, correct? I would have to create a project like the one you have stated to verify this, but the way I would approach it is to declare ControlA in ControlB and instantiate ControlA in its Control_Initialize event (like the answer I received earlier). Then, in ControlA, create a public property that sets ControlA's Enable to True or False. Then, inside ControlB you should be able to enable or disable ControlA as you need to. Again, without making the project, this is what I have in my head....but I am sure it can't be as easy as that, my luck just isn't that good. Somehow I know this might be something I will need to do, so if you find the answer to this (controlling one ocx from inside another), please be sure to let me know. And for what it is worth, I hope this has helped. -- Andrew
Quote: > Hey Thanx, but my problem is somewhat different. > See I have created an Active X EXE in VB. > Now it has various child forms in it. > All of these child forms have certain custom built OCX's in them. All of > these custom built OCX have a public exposed methods Enable and Disable. > Example. We have 2 OCX. > ocxA (On Child from frmA) > ocxB (On Child from frmB) > From the main from to disable the OCX A I will write. > frmA.ocxA.Disable > It works great. > NOW MY PROBLEM > How do I call the disable method of ocxA from inside ocxB(not frmB) I assume > I wil have to get the pointer to the current running instance of ocxA in > memory. > I tried something like this inside ocxB code. > Dim objA as Object > Set objA = GetObject(ocxA.SomeClassID) > This does not work. Help me out man. > Reagrds > Umesh Balani
> > This is the answer I received and it worked like a champ: > > In the module: > > Private UC as [Name of the usercontrol] > > In the Usercontrol_Initialize(): > > Set UC = Me > > So you can reference the Usercontrol. > > -- Andrew
> > > Hey, > > > same problem with me.. > > > can u help please .
> > > > Hey all, > > > > This may be a dumb question..... > > > > What is the method to reference an ActiveX Control from inside a > Module > > > (or > > > > Class Module)? If I only declare the UC I get <Object or Variable not > > > set>, > > > > but if I try to then instantiate the UC, it does not show in the > > > > IntelliSense list and I get "Not Defined" error. > > > > I need to use a UC, I need to use a Module, and I need to change the > > value > > > > of an object within the UC from within the Module. Could use a > pointer > > > > here. All help is greatly appreciated! > > > > -- Andrew
|
Mon, 20 Sep 2004 15:22:39 GMT |
|
 |
Umesh Balan #7 / 7
|
 Referencing a UserControl inside a Module
thanx pal, will surely let you know.
Quote: > Umesh, > Well hmmmm.... I am not by any stretch of the imagination an ocx > guru.....yet. And I have not yet tried creating an ActiveX EXE app, or used > two custom ocx's at the same time, but to me at this point it really doesn't > sound like that makes a difference. The way I understand controls, is that > from outside the control, other objects only have access to the properties, > methods and events exposed as public by that control. Just so I am on the > same page with you, I take by your stating Disable you are not trying to do > ControlA.Enable = False from inside ControlB, correct? > I would have to create a project like the one you have stated to verify > this, but the way I would approach it is to declare ControlA in ControlB and > instantiate ControlA in its Control_Initialize event (like the answer I > received earlier). Then, in ControlA, create a public property that sets > ControlA's Enable to True or False. Then, inside ControlB you should be > able to enable or disable ControlA as you need to. Again, without making > the project, this is what I have in my head....but I am sure it can't be as > easy as that, my luck just isn't that good. > Somehow I know this might be something I will need to do, so if you find > the answer to this (controlling one ocx from inside another), please be sure > to let me know. And for what it is worth, I hope this has helped. > -- Andrew
> > Hey Thanx, but my problem is somewhat different. > > See I have created an Active X EXE in VB. > > Now it has various child forms in it. > > All of these child forms have certain custom built OCX's in them. All of > > these custom built OCX have a public exposed methods Enable and Disable. > > Example. We have 2 OCX. > > ocxA (On Child from frmA) > > ocxB (On Child from frmB) > > From the main from to disable the OCX A I will write. > > frmA.ocxA.Disable > > It works great. > > NOW MY PROBLEM > > How do I call the disable method of ocxA from inside ocxB(not frmB) I > assume > > I wil have to get the pointer to the current running instance of ocxA in > > memory. > > I tried something like this inside ocxB code. > > Dim objA as Object > > Set objA = GetObject(ocxA.SomeClassID) > > This does not work. Help me out man. > > Reagrds > > Umesh Balani
> > > This is the answer I received and it worked like a champ: > > > In the module: > > > Private UC as [Name of the usercontrol] > > > In the Usercontrol_Initialize(): > > > Set UC = Me > > > So you can reference the Usercontrol. > > > -- Andrew
> > > > Hey, > > > > same problem with me.. > > > > can u help please .
> > > > > Hey all, > > > > > This may be a dumb question..... > > > > > What is the method to reference an ActiveX Control from inside a > > Module > > > > (or > > > > > Class Module)? If I only declare the UC I get <Object or Variable > not > > > > set>, > > > > > but if I try to then instantiate the UC, it does not show in the > > > > > IntelliSense list and I get "Not Defined" error. > > > > > I need to use a UC, I need to use a Module, and I need to change the > > > value > > > > > of an object within the UC from within the Module. Could use a > > pointer > > > > > here. All help is greatly appreciated! > > > > > -- Andrew
|
Wed, 22 Sep 2004 01:02:36 GMT |
|
|
|