Question listbox in DLL

andrews

Well-known member
Joined
Nov 22, 2011
Messages
167
Programming Experience
5-10
Hi,
I have a program without a windows form that I use as a DLL in other programs.
This works fine but now I want to use a new sub in the DLL using a listbox like this :
Public sub AddToListbox(Byval lb as Listbox, Byval Grid(,) as integer)
......
end sub
But mentioning the listbox gives a error.
The program do not recognize the listbox
What can I do?
(It is clear that when I want to use the sub in the DLL my program shall contain a listbox).
Thanks for any response.
.
 
If you want to be able to use any particular type in any project then that project must reference the assembly that that type is declared in. The System.Windows.Forms.ListBox class is declared in the System.Windows.Forms.dll assembly. Just as you must reference your DLL in your application project to be able to use your types, so you must reference the WinForms DLL in your library project in order to use the types it contains. You will also want to import the System.Windows.Forms namespace if you don't want to have to qualify the name in code every time.
 
Thanks but I have added a reference to system.windows.forms
And in my program DLL: imports System.Windows.Forms.ListBox
But it do not works.
 
Once you have referenced the assembly where the type is defined, the line where you used ListBox has a blue line under it and a red square with Error Correction Options (ECO). In the ECO dialog select one of the two first ways to correct the error; either qualify the type fully, or import the namespace the type belongs to.
 
Here's what I told you to do:
You will also want to import the System.Windows.Forms namespace
Here's what you did:
And in my program DLL: imports System.Windows.Forms.ListBox
Why would you expect to get correct results when you don't follow instructions?
 
Back
Top