• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

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

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!

0
loudogz
Asked:
loudogz
1 Solution
 
drydenhoggCommented:
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.

ADH.
0
 
Arthur_WoodCommented:
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.

AW
0
 
loudogzAuthor Commented:
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!

0
 
webJoseCommented:
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. :)
0
 
Computer101Commented:
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..

Computer101
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.
0

Featured Post

Industry Leaders: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now