Solved

VB 5.0 & VC Interfacing

Posted on 1998-08-04
2
159 Views
Last Modified: 2010-04-02
How does one call a function written in Visual C++ from Visual Basic 5.0??
0
Comment
Question by:pmaurin
2 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1169354
First of all, on the C++ side you need to declare the function as extern "C" to dissable the name decoraton.  Like
extern "C" int F(int i)
{
 return i + 1;
}

You also need to declare the function on the VB side so that the correct parameters are passed to VC.  I can't help you there.
0
 
LVL 2

Accepted Solution

by:
shchuka earned 100 total points
ID: 1169355
See my answer to this question in the VB area.
basically, you need
void _declspec(DllExport) _stdcall CFunction(paramlist)
Also you need the DEF file:
LIBRARY
    dll-name
EXPORT
    CFunction

In VB then you declare it as
declare sub (or function) CFunction lib "Whatever.dll" (paramlist)

and call it from VB as any other VB function.

declare
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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

912 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