hi.......can anyone tell me how do i call a subroutine created inside my dll from another project

example:-

i hv created a dll having a sub-routine named "initialize" in it .....when i call this sub-routine from my project after having made all the necessary declarations its giving me an error showing "entry point not found for initialize in enc.dll" which is the name by which i have created the dll....

initialize is having two string type parameters passed to it....
and i am calling the dll as
initialize a,b
where a and b both are strings.....

can anyone plz help me sort out this problem....

ho! you have started the dll programming so early? Nice. Ok.
Understand that if any DLL is to work it has to be registered.
If you do not know how to register, get back to me.

i opened up the activeX DLL and did the coding inside that....then afterwards there was a option in the file menu -"make enc.dll" which i made and saved it in the same folder as the project....

is this what is called registering a dll....???

i opened up the activeX DLL and did the coding inside that....then afterwards there was a option in the file menu -"make enc.dll" which i made and saved it in the same folder as the project....

is this what is called registering a dll....???

No, when you make the dll from your project that dll will be available to that project. To make the component available to all applications you have to register.

You problem, I think is the entry point in the DLL. Normally this is done by a
Sub Window_onLoad()
as the first entry point
or

Sub loadSomename()

or just like a function

Public Function GetWhatIwant(Optional ByVal somthing As String...etc)

Dim myRecordSet As New ADODB.Recordset

bind all properties to myRecordSet and Open it with SQL select
etc etc.

A Dll is a piece of excutable code that is loaded in the same memory segment of the application which uses it.

Since DLL is compiled with VB the VB runtime DLL is also required.

If all these things are greek to you, just ignore now. You will definitely understand all these things later.

i am sorry sir....but i could not actually get how to specifically specify the entry point....

Hi Anud,

Compile the .dll file.
In New VB Project, Just Go To References and Add the .dll File By Browsing, VB will Register it for u, u dont have to Register it.

Then Call the Dll Functions/Procedures in ur New Project By Instancing it using "New" keyword.

Regards
Veena

thanx veena .....but when i am trying to browse and add the dll refrence in my new project....it doesnt show up in the available refrences .....it means that it is not bein added .....

Hi Anud,

It will not be in the List, u have to manually Browse it.
Or
Once again open the Dll Project and Compile Again. Now Save It in Some Other Filder.

In ur Main Project, Browse it from the new folder..

Regards
Veena

Hi Anud,

Compile the .dll file.
In New VB Project, Just Go To References and Add the .dll File By Browsing, VB will Register it for u, u dont have to Register it.

Then Call the Dll Functions/Procedures in ur New Project By Instancing it using "New" keyword.

Regards
Veena

Veena is absolutely correct

tried it but it is not working.....still showing the error "cannot find entry point for function in the dll"....

Hi Anud,

Change the Sub Routine Name from "Initialize" to some other name.

"Initialize" is a Reserved Key Word in VB.

Regards
Veena

Anu,
you start you dll with the folling name

Public Function Initializeme(Optional ByVal somthing As String...etc)
Complie it and run.

In you project window, see that it appears along with all the forms you have created. I think if it appears there is no need of registering explicitly.

For other programs a registration is a must and you register it in MSDos prompt, like this

C:\windows\system\REGSVR32 enc.dll

I think this is not required in your case.

actually what i did was .....in the project properties under the debugging tag....i specified the start programme as the exe file of my project....and then when i am running the dll....its showing the same error as it is showing wen i run the project.....that is "cant find dll entry point "....

Please send me the piece of code of your dll, only few lines from the start.
And also few lines top and few lines bottom of the calling line of your main program. I thing I can help you only this way.

Public Function Initialize(sUserName As String, sPassword As String)
CboUserName.AddItem (sUserName)
CboPassword.AddItem (sPassword)
End Function
Public Function ShowForm() As Boolean

Form1.Show
End Function

Public Function PassCheck() As Boolean
If Ctr1 = 1 Then
PassCheck = False
Else
PassCheck = False
End If
End Function

the above one is the dll code

Declare Sub ShowForm Lib "enc1.dll" ()
Declare Sub Initialize Lib "enc1.dll" (ByVal sUserName As String, ByVal sPassword As String)
Declare Function PassCheck Lib "enc1.dll" () As Boolean

then in the sub i am calling....

ShowForm

and its giving an error "cant find dll entry point for ShowForm in enc1.dll"....

Hi Anud,

U dont need to use "Declare". U have to use "Dim"
Note :"Declare" Is used for windows "API"'s

Just Include the ".dll" in Project.
To call that dll....

Dim MyDll As New ProjName.ClassName

And Now, MyDll Exposes all the Procedures/Functions/Public Variables.

In the Calling Project remove all the "Declare" Part.

Public Function Initialize(sUserName As String, sPassword As String)
CboUserName.AddItem (sUserName)
CboPassword.AddItem (sPassword)
End Function
Public Function ShowForm() As Boolean
 
Form1.Show
End Function
 
Public Function PassCheck() As Boolean
If Ctr1 = 1 Then
PassCheck = False
Else
PassCheck = False
End If
End Function

the above one is the dll code

Declare Sub ShowForm Lib "enc1.dll" ()
Declare Sub Initialize Lib "enc1.dll" (ByVal sUserName As String, ByVal sPassword As String)
Declare Function PassCheck Lib "enc1.dll" () As Boolean

then in the sub i am calling....

ShowForm

and its giving an error "cant find dll entry point for ShowForm in enc1.dll"....

That's very correct. your dll has only 2 functions. where is showform?

show form is there sir......its not indented properly....but it is there

I am sorry. Ok. I will join you, within few minutes.

Ok. What veena says can be true up to certain extent of the environment you design your code and test run it. But as far as I understand even objects can be declare as Anu has done.

But the Dim statement can be used for a test.

In your Dll Calling program module just enter the following.

Dim myShow as New

As soon as You type New, see that all available components to your project are available or not

Note that the complete name of the component is made up of the name of the project , followed by a dot and the name of the subObjects.

In that if your functions in the dll (all) appears please get back to me.

thanks a lot to you sir and veena.....what veena told me worked out to be absolutely fine.....i was able to access all the functions and sub-routines declared in my dll by using dim .....

Hi, Veena you are really helpfull for Anu.
Thanks.

Hi,

Manoharan, Anud Thanks
I came to know his problem only when he pasted his code..


Regards
Veena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.