MS Access to use a DLL  I created in C++!

Posted on 2003-02-25
Medium Priority
Last Modified: 2013-11-25
I created a dll (dialog) in C++, and I don't know if Visual Basic can link to a DLL (created in VC++).  Is there a way?

Thanks in Advance!

Question by:loudogz
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8016305
Register the DLL (regsvr32 dllpath/dllname) and reference it from the VB project just like any other dll.

Alternative ways to access it include delaring it just like an api function within the VB project, but thats excessive, given a simple reference will work.

LVL 44

Expert Comment

ID: 8016548
drydenhogg,  that will ONLY work IF the C++ DLL has in fact been created as a COM compliant DLL, and most C++ DLLs ARE NOT COM-compliant.  The second option requires that the EXPORTS from the C++ code be properly declared, to be accessible from your VBA code.


Author Comment

ID: 8016657
Arthur Wood!

I found out from the documentation that you have you declare your dll.  It's not exactly clear how.... I guess my questio is how do you declare a mfc dialog dll from visual basic and how do you call it?...Has anyone done this before...

Thanks for all the replies so far!


Accepted Solution

webJose earned 400 total points
ID: 8030785
What you need to do is export functions.  I prefer creating a definition file (.def) with an EXPORTS section.

In there, you export a function that does the call to the MFC dialog.  That is all.  VB does not have to know about this.  Example (I don't know MFC so I will not show MFC-related code):

BOOL ShowDialog(DataStruct* pData)
    //Here you put the code for initializing and showing the dialog
    return TRUE;

Then, in VB, you need to add a Declare statement:

Type DataStruct
End Type

Declare Function ShowDialog Lib "Mydll.dll"(ByRef pData as DataStruct) As Long

Now you are able to use the ShowDialog function. :)

Expert Comment

ID: 8039493
A request has been made to change the grade,  The expert feels the current grade does not fit the criteria of the intended guidelines.  Those guidelines are below.  If no response, I will review this question and grade accordingly..

E-E Admin

How Do I Know What Grade to Give?
Although we use an A-D scale here at Experts Exchange, it works differently than, say, school grades. If one or more Experts' proposals are accepted as answers, they should usually be given an A or B grade, since they have taken the time to provide you with a working solution. If a possible solution is incomplete - ask for clarification or details before accepting the answer and grading it. People should not be given lower grades because of incorrect grammar or because you just accepted their answer or comment to close the question. Keep in mind, your question and any follow-up comments should be focused so that there can be a specific answer. The following is a good guideline to follow when grading:

A: The Expert(s) either provided you with a thorough answer or they provided you with a link to information that thoroughly answered your question. An "A" can also be given to any answer that you found informative or enlightening beyond the direct question that you asked.

B: The Expert(s) provided an acceptable solution, or a link to an acceptable solution, that you were able to use, although you may have needed a bit more information to complete the task.

C: Because Experts' reliability are often judged by their grading records, many Experts would like the opportunity to clarify if you have questions about their solutions. If you have given the Expert(s) ample time to respond to your clarification posts and you have responded to each of their posts providing requested information; or if the answers, after clarification, lack finality or do not completely address the issue presented, then a "C" grade is an option. You also have the option here of just asking Community Support to delete the question.

Remember, the Expert helping you today is probably going to be helping you next time you post a question. Give them a fair chance to earn an 'Excellent!' grade and they'll provide you with some amazing support.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…

765 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