Solved

Visual Basic 5.0 and Visual C++ Interfacing

Posted on 1998-08-04
2
157 Views
Last Modified: 2013-11-25
How does one call a Visual C++ function from Visual Basic 5.0 program??
0
Comment
Question by:pmaurin
2 Comments
 

Expert Comment

by:Tbird
ID: 1467812
There are many was to get access to Visual C++ Code.

You can Write an OCX control in Visual C++.

You can Write a DLL that exposes functions, etc.

Which are you interested in?

If it is an OCX you merly need to add the OCX to your project and its properties methods and events are exposed.

If it is a DLL you must declare the function like any other DLL.
0
 
LVL 2

Accepted Solution

by:
shchuka earned 100 total points
ID: 1467813
You need to compile the C++ functions into a DLL

Declare your functions such as
void _declspec(DLLExport) _stdcall CFunction(paramlist)

You'll also need the DEF file, which will look like this:

LIBRARY
    dll-name
EXPORT
    CFunction

After you compiled it, you'll get a .dll file, say CFunction.dll

In you VB program, you'll declare it using

(use sub for void, fucntions for everything else)
declare sub CFunction lib "CFunction.dll" (paramlist)

After that you can call it as you would any function.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSIS 2010 Convert to SSIS 2013 On Different Box 3 56
Build VS2015 project in bat command 3 79
Copy a row 12 57
vb6 connector to mongodb 2 45
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

948 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

22 Experts available now in Live!

Get 1:1 Help Now