How to pass a VB intrinsic Control as parameter to an ActiveX control (UserControl) 
Author Message
 How to pass a VB intrinsic Control as parameter to an ActiveX control (UserControl)

I have an ActiveX control (UserControl) that is to perform operations on
other peer controls.  (like a resizer OCX would).
But when I declared a method that takes a Control as a parameter, I got the
following error message:

"Private object modules cannot be used in public object modules as
parameters or return types for public procedures, as public data members, or
as fields of public user defined types"

But if my method isn't public, how will the parent be able to pass me a
control as a parameter?

I tried declaring the parameter as a variant, and passing the Control that
way, but VB passed the control's Text value as a variant string, rather than
passing the whole control as a variant object.

Any hints?

TIA



Tue, 25 Nov 2003 05:26:41 GMT  
 How to pass a VB intrinsic Control as parameter to an ActiveX control (UserControl)
I do that all the time myself...passing arrayof of UDTs and passing UDTs
etc.

Declare as Friend sub/function. Not Public.  Catch: you will never be able
to use that control in a compiled ActiveX OCX, that usercontol will have to
be included in the sorce of the project(s) it's used in.


Quote:
> I have an ActiveX control (UserControl) that is to perform operations on
> other peer controls.  (like a resizer OCX would).
> But when I declared a method that takes a Control as a parameter, I got
the
> following error message:

> "Private object modules cannot be used in public object modules as
> parameters or return types for public procedures, as public data members,
or
> as fields of public user defined types"

> But if my method isn't public, how will the parent be able to pass me a
> control as a parameter?

> I tried declaring the parameter as a variant, and passing the Control that
> way, but VB passed the control's Text value as a variant string, rather
than
> passing the whole control as a variant object.

> Any hints?

> TIA



Tue, 25 Nov 2003 05:36:19 GMT  
 How to pass a VB intrinsic Control as parameter to an ActiveX control (UserControl)

Quote:
> I have an ActiveX control (UserControl) that is to perform operations on
> other peer controls.  (like a resizer OCX would).
> But when I declared a method that takes a Control as a parameter, I got
the
> following error message:

Declare it "As Object"


Tue, 25 Nov 2003 05:35:44 GMT  
 How to pass a VB intrinsic Control as parameter to an ActiveX control (UserControl)


Fri, 19 Jun 1992 00:00:00 GMT  
 How to pass a VB intrinsic Control as parameter to an ActiveX control (UserControl)
WARNING

That would make the referance LATE BOUND

would work though, no doubt about it....


Quote:


> > I have an ActiveX control (UserControl) that is to perform operations on
> > other peer controls.  (like a resizer OCX would).
> > But when I declared a method that takes a Control as a parameter, I got
> the
> > following error message:

> Declare it "As Object"



Tue, 25 Nov 2003 05:49:45 GMT  
 How to pass a VB intrinsic Control as parameter to an ActiveX control (UserControl)

Quote:
> WARNING

> That would make the referance LATE BOUND

Well, late bound isn't always a major issue - unless you are making a lot of
calls the performance issue is likely to be negligible.  Besides, you can
always re-assign it once you get the object inside your routine:

sub mysub(byval o as object)
dim c as control
set c=o ' we now have a reference using the "control" interface
' do stuff using 'c'
end sub



Tue, 25 Nov 2003 06:04:05 GMT  
 How to pass a VB intrinsic Control as parameter to an ActiveX control (UserControl)
This looks like *exactly* what I was looking for - I knew it was possible,
but I couldn't see it. I'll try tomorrow...
Thanks!

Quote:


> > WARNING

> > That would make the referance LATE BOUND

> Well, late bound isn't always a major issue - unless you are making a lot
of
> calls the performance issue is likely to be negligible.  Besides, you can
> always re-assign it once you get the object inside your routine:

> sub mysub(byval o as object)
> dim c as control
> set c=o ' we now have a reference using the "control" interface
> ' do stuff using 'c'
> end sub



Tue, 25 Nov 2003 10:17:55 GMT  
 How to pass a VB intrinsic Control as parameter to an ActiveX control (UserControl)

Quote:
> Agree

With what?

Or is that a command?



Tue, 25 Nov 2003 11:15:41 GMT  
 How to pass a VB intrinsic Control as parameter to an ActiveX control (UserControl)


Quote:
> > Agree
> With what?

> Or is that a command?

Perhaps the poster is Borg and, in our century, they say "Agree" instead of
"Comply."


Tue, 25 Nov 2003 13:00:46 GMT  
 How to pass a VB intrinsic Control as parameter to an ActiveX control (UserControl)

Quote:

> > > Agree

> > With what?

> > Or is that a command?

> Perhaps the poster is Borg and, in our century, they say "Agree" instead
of
> "Comply."

Wrong century.

Renaissance is feudal.



Wed, 26 Nov 2003 11:27:35 GMT  
 How to pass a VB intrinsic Control as parameter to an ActiveX control (UserControl)

<cut>

Quote:
> Renaissance is feudal.

LOL


Thu, 27 Nov 2003 00:48:40 GMT  
 How to pass a VB intrinsic Control as parameter to an ActiveX control (UserControl)


Fri, 19 Jun 1992 00:00:00 GMT  
 How to pass a VB intrinsic Control as parameter to an ActiveX control (UserControl)
Watch this carefully. It's technically NOT legal to pass references to
private objects publicly via AS OBJECT.

While it MAY work, it can{*filter*}up. It's not really legal COM, so test and
test again.

I've used the trick and had some success, but also had to screwups, mostly
when dealing with a multithreaded program.

Good luck!


Quote:
> I have an ActiveX control (UserControl) that is to perform operations on
> other peer controls.  (like a resizer OCX would).
> But when I declared a method that takes a Control as a parameter, I got
the
> following error message:

> "Private object modules cannot be used in public object modules as
> parameters or return types for public procedures, as public data members,
or
> as fields of public user defined types"

> But if my method isn't public, how will the parent be able to pass me a
> control as a parameter?

> I tried declaring the parameter as a variant, and passing the Control that
> way, but VB passed the control's Text value as a variant string, rather
than
> passing the whole control as a variant object.

> Any hints?

> TIA



Thu, 27 Nov 2003 12:37:48 GMT  
 
 [ 13 post ] 

 Relevant Pages 

1. Passing Parameters to stored parameter queries using VB 5's Data Controls

2. ActiveX control and passing parameters

3. Passing parameters into a ActiveX control ?

4. Help on Passing parameter to an ActiveX control in IE

5. Passing Parameters to ActiveX Control

6. Help on Passing parameter to an ActiveX control in IE

7. Passing ActiveX Control as parameter into a function

8. passing parameter from HTML to ActiveX Control

9. Passing parameters to ActiveX control

10. Passing parameters to an ActiveX Control

11. Passing Parameters to ActiveX Control

12. Help on Passing parameter to an ActiveX control in IE

 

 
Powered by phpBB® Forum Software