yingchunli
asked on
"Can't find DLL entry point"
I create a test dll named testDll (Axtivex DLL using VB5.0) that has a function TrippleVal:
Private Function TrippleVal(ByVal theVal As Integer) As Integer
TrippleVal = 3 * theVal
End Function
Then I try to use the dll in a test program(also using VB5.0):
Private Declare Function TrippleVal Lib "testDll" (ByVal v As Integer) As Integer
Public Sub Command1_Click()
Dim w As Integer
w = TrippleVal(12)
End Sub
As I run the test program, I get "can't find Dll entry point TrippleVal in testDll.dll ".
I am asking some one to help me to figure out the problem.
Private Function TrippleVal(ByVal theVal As Integer) As Integer
TrippleVal = 3 * theVal
End Function
Then I try to use the dll in a test program(also using VB5.0):
Private Declare Function TrippleVal Lib "testDll" (ByVal v As Integer) As Integer
Public Sub Command1_Click()
Dim w As Integer
w = TrippleVal(12)
End Sub
As I run the test program, I get "can't find Dll entry point TrippleVal in testDll.dll ".
I am asking some one to help me to figure out the problem.
You have TrippleVal( declared as Private, declare it as Public!
ASKER
As I declare it as Public, I got another error "...., Declare statements not allowed as public members of object modues".
Sorry, I didn't realize I a was being ambiguous. It has to be public in the DLL. You want:
Public Function TrippleVal(ByVal theVal As Integer) As Integer
TrippleVal = 3 * theVal
End Function
Then in the main program you can declare it
Private Declare Function TrippleVal Lib "testDll" (ByVal v As Integer) As Integer
Public Function TrippleVal(ByVal theVal As Integer) As Integer
TrippleVal = 3 * theVal
End Function
Then in the main program you can declare it
Private Declare Function TrippleVal Lib "testDll" (ByVal v As Integer) As Integer
ASKER
I did it previously. I still got the same "can't find Dll entry point ...." message.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Alamo:
Thank you very much for your quick answers.
I will try it next monday.
By the way, I do not surely understand "function ....should be in Class Module" ,
and why I cannot directly use the function in DLL after the declaration as mentioned in many examples rather than "refer to ActiveX DLL by using Reference menu option"?
Have a good weekend.
Thank you very much for your quick answers.
I will try it next monday.
By the way, I do not surely understand "function ....should be in Class Module" ,
and why I cannot directly use the function in DLL after the declaration as mentioned in many examples rather than "refer to ActiveX DLL by using Reference menu option"?
Have a good weekend.
Well, don't thank me, thank Anita - I got so fixated on the function being "Private" I completely ignored the fact that the ActiveX DLL is a different kind of DLL. You must treat it as an object rather than declare it.
Here's the basics of how to call your ActiveX dll. (I haven't done that much of this sort of thing so it might not be perfect, but it did work for me just now):
First, go into your DLL project. Make your function Public and save it in a Class module. Name the class Class1. Build the DLL.
Now go to your test program. In the Project menu select References, then Browse to where testdll.dll is and Open it. Make sure it's checked in the "Available references" list.
Now, in your Command1_Click() sub instead of "w = TrippleVal(12) " use:
Dim testObj As Object
Set testObj = New TestDLL.Class1
w = testObj.TrippleVal(12)
That should get you a lot farther... if I have anything wrong or missing hopefully Anita or someone else will say so. Sorry for the confusion.
Here's the basics of how to call your ActiveX dll. (I haven't done that much of this sort of thing so it might not be perfect, but it did work for me just now):
First, go into your DLL project. Make your function Public and save it in a Class module. Name the class Class1. Build the DLL.
Now go to your test program. In the Project menu select References, then Browse to where testdll.dll is and Open it. Make sure it's checked in the "Available references" list.
Now, in your Command1_Click() sub instead of "w = TrippleVal(12) " use:
Dim testObj As Object
Set testObj = New TestDLL.Class1
w = testObj.TrippleVal(12)
That should get you a lot farther... if I have anything wrong or missing hopefully Anita or someone else will say so. Sorry for the confusion.
alamo is right. However, one small note about 'Dim testObj As Object' When you have reference to your ActiveXDLL, it's better if you declare it by specifying the class name. For example, in this case declare it as Dim testObj As Class1. This way you get complete early binding.
ASKER
Anita and alamo:
It works now. Thanks to both of you.
It works now. Thanks to both of you.