Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General / November 2004



Tip: Looking for answers? Try searching our database.

Cannot pass objects to DLL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
oc7 - 25 Nov 2004 14:41 GMT
Hello, I'm trying to create a Activex DLL to use with my application. In the
DLL I would like to have  Functions/Subroutines that will use objects (Form,
Listbox, ComboBox)  as a parameter. When I try to do that I get the following
error, "Private object modules cannot be used in public object modules as
parameters or return types for public procedures…..". Routines that use
String or Integer as parameters works ok. I'm using vb6. Is there something
I'm missing. Here is a sample of my code: I

Public Sub CenterForm(ByVal objFrmName As Form)

End Sub

Thanks
Jan Hyde - 25 Nov 2004 14:53 GMT
oc7 <oc7@discussions.microsoft.com>'s wild thoughts were
released on Thu, 25 Nov 2004 06:41:03 -0800 bearing the
following fruit:

>Hello, I'm trying to create a Activex DLL to use with my application. In the
>DLL I would like to have  Functions/Subroutines that will use objects (Form,
[quoted text clipped - 9 lines]
>
>Thanks

Only VB knows what a listbox etc are therefore you cannot
expose these in any public way. You will have to use 'as
object' instead.

Jan Hyde (VB MVP)

Signature

Archeological trip: Bone voyage.

[Abolish the TV License - http://www.tvlicensing.biz/]

oc7 - 25 Nov 2004 16:27 GMT
Hi Jan, thanks for your help. I changed the code from Form to Object and it
works. Are there any disadvantages/limitations with everything being declared
as an Object.

> oc7 <oc7@discussions.microsoft.com>'s wild thoughts were
> released on Thu, 25 Nov 2004 06:41:03 -0800 bearing the
[quoted text clipped - 19 lines]
>
> Jan Hyde (VB MVP)
Jan Hyde - 25 Nov 2004 17:07 GMT
oc7 <oc7@discussions.microsoft.com>'s wild thoughts were
released on Thu, 25 Nov 2004 08:27:02 -0800 bearing the
following fruit:

>Hi Jan, thanks for your help. I changed the code from Form to Object and it
>works. Are there any disadvantages/limitations with everything being declared
>as an Object.

Yes. See Martin's response.

Personally I'd avoid passing these kind of object if you
can.

J

>> oc7 <oc7@discussions.microsoft.com>'s wild thoughts were
>> released on Thu, 25 Nov 2004 06:41:03 -0800 bearing the
[quoted text clipped - 19 lines]
>>
>> Jan Hyde (VB MVP)

Jan Hyde (VB MVP)

Signature

Did you hear about the guy who blamed arithmetic for his divorce?
His wife put two and two together.

(Art. Moger)

[Abolish the TV License - http://www.tvlicensing.biz/]

Douglas Marquardt - 25 Nov 2004 18:20 GMT
You can still take advantage of early binding on the
recv end by assigning the object to a variable of it's type, i.e.

Public Sub CenterForm(ByVal objFrmName As Object)
  Dim frm As Form
  Set frm = objFrmname
  ...etc
End Sub

Doug.

> Hi Jan, thanks for your help. I changed the code from Form to Object and it
> works. Are there any disadvantages/limitations with everything being declared
[quoted text clipped - 23 lines]
> >
> > Jan Hyde (VB MVP)
Martin Walke - 25 Nov 2004 16:31 GMT
Jan,

The only problem with that is that you have to then rely on late-binding.

We developed an ActiveX DLL solution a couple of years ago which suddenly
started reporting errors "...disconnected from the server.." (can't remember
the exact message). Although there was no actual solution found, most of the
suggestions were directed towards ensuring that the app was using
early-binding not late.

The way we tried to get around this was to use as you suggested ..as Object
and then in the procedure assign the passed value to an actual control

Public Sub CentreForm (objForm as Object, objCombo as object)

 dim f as Form, c as ComboBox

 set f = objForm
 set c = objCombo
 :
 :
End Sub

Martin

> oc7 <oc7@discussions.microsoft.com>'s wild thoughts were
> released on Thu, 25 Nov 2004 06:41:03 -0800 bearing the
[quoted text clipped - 19 lines]
>
> Jan Hyde (VB MVP)
oc7 - 25 Nov 2004 20:11 GMT
Thanks for all the suggestions. I'll make sure I use early-binding.

> Jan,
>
[quoted text clipped - 48 lines]
> >
> > Jan Hyde (VB MVP)
Ken Halter - 29 Nov 2004 16:35 GMT
> Thanks for all the suggestions. I'll make sure I use early-binding.

Be careful what you pass. ActiveX Controls are a bear. They work fine until
you deploy the app.

PRB: Passing ActiveX Control to Component Gives "Type Mismatch" Error
Message
http://support.microsoft.com/default.aspx?scid=kb;en-us;190210

Signature

Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep all discussions in the groups..

oc7 - 30 Nov 2004 14:51 GMT
Hi Ken, I'm currently just developing the application so it hasn’t been
deployed as yet. But thanks for the warning.

oc7

> > Thanks for all the suggestions. I'll make sure I use early-binding.
>
[quoted text clipped - 4 lines]
> Message
> http://support.microsoft.com/default.aspx?scid=kb;en-us;190210
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.