Solved

"Can't find DLL entry point"

Posted on 1998-06-30
9
145 Views
Last Modified: 2010-05-03
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.  
0
Comment
Question by:yingchunli
  • 4
  • 3
  • 2
9 Comments
 
LVL 6

Expert Comment

by:alamo
Comment Utility
You have TrippleVal( declared as Private, declare it as Public!
0
 

Author Comment

by:yingchunli
Comment Utility
As I declare it as Public, I got another error "...., Declare statements not allowed as public members of object modues".  
0
 
LVL 6

Expert Comment

by:alamo
Comment Utility
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
0
 

Author Comment

by:yingchunli
Comment Utility
I did it previously. I still got the same "can't find Dll entry point ...." message.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 1

Accepted Solution

by:
Anita030598 earned 30 total points
Comment Utility
Ypu don't declare thr functions for ActiveX dlls. Instead you will have to refer to ActiveX DLL by using Reference menu option. Also your function should be public and should be in Class Module.
0
 

Author Comment

by:yingchunli
Comment Utility
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.
0
 
LVL 6

Expert Comment

by:alamo
Comment Utility
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.
0
 
LVL 1

Expert Comment

by:Anita030598
Comment Utility
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.
0
 

Author Comment

by:yingchunli
Comment Utility
Anita and alamo:

It works now. Thanks to both of you.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now