Author |
Message |
Brian Biale #1 / 13
|
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 |
|
|
schunkenstei #2 / 13
|
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 |
|
|
Bob Butle #3 / 13
|
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 |
|
|
#4 / 13
|
How to pass a VB intrinsic Control as parameter to an ActiveX control (UserControl)
|
Fri, 19 Jun 1992 00:00:00 GMT |
|
|
schunkenstei #5 / 13
|
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 |
|
|
Bob Butle #6 / 13
|
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 |
|
|
Biales, Bria #7 / 13
|
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 |
|
|
Bob Butle #8 / 13
|
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 |
|
|
Jeff Johnso #9 / 13
|
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 |
|
|
Steve Rindsber #10 / 13
|
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 |
|
|
Bob Butle #11 / 13
|
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 |
|
|
#12 / 13
|
How to pass a VB intrinsic Control as parameter to an ActiveX control (UserControl)
|
Fri, 19 Jun 1992 00:00:00 GMT |
|
|
Dari #13 / 13
|
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 |
|
|