Solved

"Can't find DLL entry point"

Posted on 1998-06-30
9
147 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
ID: 1464643
You have TrippleVal( declared as Private, declare it as Public!
0
 

Author Comment

by:yingchunli
ID: 1464644
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
ID: 1464645
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:yingchunli
ID: 1464646
I did it previously. I still got the same "can't find Dll entry point ...." message.
0
 
LVL 1

Accepted Solution

by:
Anita030598 earned 30 total points
ID: 1464647
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
ID: 1464648
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
ID: 1464649
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
ID: 1464650
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
ID: 1464651
Anita and alamo:

It works now. Thanks to both of you.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

770 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