I have create the dll from VB6. my dll name is "Project1"
So how I can use the dll I have created such as call the form from command button through the dll.
Printable View
I have create the dll from VB6. my dll name is "Project1"
So how I can use the dll I have created such as call the form from command button through the dll.
Go to "Project" -> "References", tick the box next to the DLL, and press OK.
Then add code like this:
You need to replace Project1 with whatever code name you gave your DLL, and Class1 with a class that it exposes (they will be listed when you type the . )Code:Dim MyObject as Project1.Class1
Set MyObject = New Project1.Class1
'code to work with MyObject
Set MyObject = Nothing
I got the error message while adding in References
For this line "'code to work with MyObject". What is the example?
The error means that the library name you chose for the DLL isn't unique - you have another item in your project (or even the project itself) which has the same name (which you set under "Project" -> "Properties"). Give the DLL a name which is unique, and try again.
As to the "'code to work with MyObject" part, that is entirely dependent on the code in your DLL - but would be the same as if you were using the class directly in the same project.
This is the first time I used dll.
I have design the form1,form2 and also name the class1 and save it as project2
But How I can access the form in the class? I can see the class1 list. I also add it as reference.But When typing MyObject , the from1 and form2 not listed. How to list it? hopes learning from the sample attach file from you
Dim MyObject As Project2.Class1
Set Myobject = New Project2.Class1
Compile the DLL project and create a .dll file.Add this .dll as a reference to your project.
I have done it. I don't know what wrong.
Could you attach me one sample and put one form and one class. I would like to look why my form not list.
Could you post the sample code ? I'm not sure about your requirement.
You have one project with a form and class .And you want to access the form in the class ?
Here is a sample attached .Hope this helps.Quote:
Originally Posted by matrik02
Quote:
Originally Posted by martrik02
?? I'm not sure of the question.In the class1.cls is accessing form1
Could you post the sample code that you have implemented ?
Sorry,
Actually I would like to create the dll from your sample.
Then I open another project, I add your dll as reference and would like to showed the form when I click the button on the form I design. Something like that.
Thank you, I work now. Hi, I have modify your code. I put the function in the class. Thank you both of youQuote:
Originally Posted by amrita