tags:

views:

102

answers:

2

Hello there, I was reading a little into Visual Basic and it seemed a rather simple way to implement some GUI...So I was looking for a way to interface my C++ code to a Visual Basic snippet of code. For example, receive input from a Visual Basic app and send it over to C++ code to continue the logic of the program based on the input of that event.

+3  A: 

If you are talking about VB6 then the normal way is to create COM objects in C++ and use them from VB6, however I think in the long run you would benefit from - presuming Windows/Microsoft is your platform of choice - going over to .NET. You could convert your C++ code to C++/CLI and use VB.NET or better C# as GUI language. (caveat: You may also then come to like C# so much that you write the whole app in C# in the end).

Anders K.
It is still the same way for VB.NET or C# code. `<ComVisible(True)>` attribute.
Hans Passant
VB.NET / C# code interop with C++ would be *a lot* easier. You can use Managed C++ to get at the VB.NET / C# classes. *COM is evil*
Scott P
Please, not Managed C++. Anders is right to suggest C++/CLI, which back in 2005 totally replaced the buggy piece of garbage called Managed Extensions for C++.
Ben Voigt
A: 

You have some options :

  1. You could create a Visual Basic GUI and create some Dynamic link libraries (DLL) for your C++ code. In order to call the C++ code, you would have to put the necessary measures so that your GUI can communicate with the C++ code.

  2. You can drop the idea of using Visual Basic and use C++ with a cross-platform library such as Qt.

  3. You can drop the idea of using Visual Basic and use C++ with MFC.

Alerty
You forgot one pretty obvious option: "You can drop the idea of using C++ and use Visual Basic"
jalf
@jalf: I did not include this option because he already has some code done in C++. Why reinvent the wheel when you have code that can be used again.
Alerty