Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Calling .dll and Passing to it Arguments of Type Form, Combo box and The Like


Calling .dll and Passing to it Arguments of Type Form, Combo box and...

Author
Message
Matt
Matt
Forum God
Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)

Group: Forum Members
Posts: 17, Visits: 23

Is there a way to have the ability to call a dll and pass to it arguments of type form, combo box , etc.

I have a VB exe project which I am trying to split into an exe and dll that works together. I have no problem doing this except that for me some portions of my code which represented convenience in the past has now become a pain in the neck.

I am talking about the error message:

“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.”

When I separated my class and tried to compile its corresponding .dll I keep getting the error above whenever the arguments I passed are or type combo box , form and the like. When I was working with those classes from the exe project, passing these types in said classes has been really convenient for me and although I know how to work around this problem by changing the said class function so that it does not pass said types – it now has become a pain considering the size of the application and the number of functions affected.

Also, if there is a way to call said types by tricking the compiler somehow, then I could enjoy the freedom of doing what I have described in future projects without doing a lot of internal changes in the functions affected.

I did try to get a book and read about these things before I experimented to avoid this kind of nightmare – but I do not know why they did not seem to mention about this problem.

Thank you so much for all the kind help you can give.

Gratefully,
Matt


pso
pso
Forum God
Forum God (73K reputation)Forum God (73K reputation)Forum God (73K reputation)Forum God (73K reputation)Forum God (73K reputation)Forum God (73K reputation)Forum God (73K reputation)Forum God (73K reputation)Forum God (73K reputation)

Group: Forum Members
Posts: 794, Visits: 338
In your public subs,functions...within your class,
place your types as Objects and then deal with them.

you could also rewrite your class to include other helper classes that can prevnt this sort of thing in future.
if you try to pass Private sub Combobox1(..) into your Public Function ReturnItem(byval cbItem as Combobox) there is your error. Private object -combobox1 into Public function . Your DLL doesn't know what the heck type Combobox is because it only knows what you tell it .

So you may also have success making Combobox1 - in the form - a Public Sub Combobox1 (....), then pass it to your DLL, but what if you forget about doing this to all those objects on form in future projects that use your DLL?

So the work araound for you, right now would be probably something similar to:

Public Function MyFunctionInMyDLL(Byref f as Object)
Dim frm As Form
Set frm = f
' do something
'return something to form being referenced
End Function

hope that helps.

learn how to refactor








Tongue

GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search