Referencing a UserControl inside a Module 
Author Message
 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  
 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  
 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  
 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  
 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  
 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  
 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  
 
 [ 7 post ] 

 Relevant Pages 

1. calling a sub inside a usercontrol from a module

2. calling a sub inside a usercontrol from a module

3. calling a sub inside a usercontrol from a module

4. Please help me reference an API function declaration from inside a module

5. UserControl reference in a class or .bas module

6. Q: Code Module vs UserControl (Form, Class) module.

7. Q: Code Module vs UserControl (Form, Class) module.

8. Q: Code Module vs UserControl (Form, Class) module.

9. Circular Reference Between Modules when 2 Class Modules Listen to Each others Events

10. Circular Reference Between Modules when 2 Class Modules Listen to Each others Events

11. Form's validate does not fire usercontrol(inside textbox) validating event

12. Controls inside UserControl

 

 
Powered by phpBB® Forum Software