cano63
asked on
DLL
I would like to know how can i made a proyect to be a dll field and call it from a main proyect
Any one can give me an example in VB 6.0
Any one can give me an example in VB 6.0
ASKER
can you give a link or a place that i can find an example. I tried to make a dll but it don,t want to compile it give and error
not creable public content find
not creable public content find
Are you using VB6 or VB.NET?
ASKER
vb6.0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This code works as printed, but I wanted to see how changes work.
I made a change to see what would happen,
ORIGINAL CODE:
Public Sub Sub2()
MsgBox "Class2.Sub2"
End Sub
NEW CODE
Public Sub Sub2()
MsgBox "This is Class2.Sub2"
End Sub
The dll compiles OK
I get the error:
Could not create reference: 'Sample Dll\Project1DLL.dll'
when I try to run my EXE project
I even tried to run RegSvr32 again
If I copy in the original code again, it works fine
I made a change to see what would happen,
ORIGINAL CODE:
Public Sub Sub2()
MsgBox "Class2.Sub2"
End Sub
NEW CODE
Public Sub Sub2()
MsgBox "This is Class2.Sub2"
End Sub
The dll compiles OK
I get the error:
Could not create reference: 'Sample Dll\Project1DLL.dll'
when I try to run my EXE project
I even tried to run RegSvr32 again
If I copy in the original code again, it works fine
To create a VB DLL, all you have to do is create a new project and select ActiveXDLL as the project type. Your DLL can have Forms, Classes, and Modules just like an VB EXE project. However, functions inside of Modules are invisible outside the DLL. Classes and Forms with an instancing property of Private can only be accessed from within the DLL. Classes and Forms with an instancing property of Multiuse can be created and used from outside the DLL. Classes and Forms with an instancing of Public-Noncreatable means the public functions of object can be called, but a project outside the DLL can not create an instance of the object. Classes and Forms with an instancing of Pulic MultiUse means an instance of the Class exists and functions of that class can be called without creating an instance of the object. In this repect, the VB ERR object is an example of a class declared as Global-Multiuse because your VB project already has an instance of the ERR object without you doing anything.
Now I might have some of these exact property names a little wrong as I'm going from memory and currently do not have access to my computer with VB6 installed on it.
Once you compile your DLL, it will automatically be registered on your machine. To use it on another machine, you will have to register it with RegSvr32.
To use the DLL in another project, you just have to reference it from your EXE project (goto the menu options for selecting references).