VisualBasic

Hi, I have an application that has about 3 subroutines that I'd like to use in another application so I decided to move them out into a DLL. Anyway, I moved them out and I call them from the two applications and they all work fine. When I moved them out, I temporarily commented out anything to do with the user interface - basically the routines do some processing of files that sometimes takes a long time so in the original application, the routines would update a little status form

What I'd like to do is popup the status form in each of the two applications and then call the subroutines in the DLL and then have the subroutine update the form. So I decided to add a simple textbox control in the subroutines' parameter list. When I go to compile the DLL I get

Compile error
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 type

This is the test subroutine that gives me the compile error

Public Sub test(t As Control
t.Text = "foobar
End Su

Am I stuck, am I doing something wrong? Is there a way around it? Any other suggestion of how to do what I'd like? Thanks

Re: passing a textbox control in parameter list

Ken

The DLLs you create with VB are supposed to support any language that supports ActiveX...
which means that you can't expose VB specific controls to the public.

About all you can do is.....
> Public Sub test(t As Object)
> t.Text = "foobar"
> End Sub

... and even then you should pass only intrinsic controls. If you try to pass an ActiveX
control you'll end up with a type-mismatch on the end users system. See article below if
interested.

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

Some people go this way so they can get intellisense...

> Public Sub test(t As Object)
Dim o As TextBox
Set o = t 'raise an error if the developer passed anything but a textbox.
> o.Text = "foobar"
> End Sub

That's no safer for ActiveX controls though.

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


"sr" <anonymous@discussions.microsoft.com> wrote in message
news:4EC4FF39-AE02-4A43-8DF6-7522D41CF680@microsoft.com...
> Hi, I have an application that has about 3 subroutines that I'd like to use in another
application so I decided to move them out into a DLL. Anyway, I moved them out and I
call them from the two applications and they all work fine. When I moved them out, I
temporarily commented out anything to do with the user interface - basically the routines
do some processing of files that sometimes takes a long time so in the original
application, the routines would update a little status form.
>
> What I'd like to do is popup the status form in each of the two applications and then
call the subroutines in the DLL and then have the subroutine update the form. So I
decided to add a simple textbox control in the subroutines' parameter list. When I go to
compile the DLL I get:
>
> Compile error:
> 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
>
>
> This is the test subroutine that gives me the compile error:
>
> Public Sub test(t As Control)
> t.Text = "foobar"
> End Sub
>
>
> Am I stuck, am I doing something wrong? Is there a way around it? Any other suggestion
of how to do what I'd like? Thanks.
>