Solved

"Can't find DLL entry point"

Posted on 1998-06-30
9
148 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adding to a VBA? 6 78
Getting warning: You are about to delete 1 row(s) 9 52
VB6 ListBox Question 4 48
Need Nag Screen for Reboot if system up time is over 14 days 12 62
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

828 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