Solved

VB 5.0 & VC Interfacing

Posted on 1998-08-04
2
162 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

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.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

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