Visual Basic and C++ and Debug and DLLs

Here is the problem I am having now. I have a C++ DLL that seems to work just fine. It has been tested with function calls from a executable written in C++. Now, using it with my Visual Basic GUI seems to be ok up to a point. The Visual Basic program compiles and "links" (for lack of a better term to use) with the DLL written in C++. But it seems that I cannot pass the same sort of variables back and forth between the Visual Basic program and the DLL. It seems to crash on the DLL side after a function call is made.

So my question is this. How can I run the two -- the Visual Basic GUI and the C++ DLL -- in debug mode so that I can watch what is happening on the DLL side?

And/Or, if I put a printf statement in the DLL C++ code, where would the output go to?

But it seems that I cannot pass the same sort of variables back and forth between the Visual Basic program and the DLL. It seems to crash on the DLL side after a function call is made.

Could you post your C++ function interface AND the way you declare this one in VB?

How can I run the two -- the Visual Basic GUI and the C++ DLL -- in debug mode so that I can watch what is happening on the DLL side?

That depends on your C++ development environment. Though I've not had your exact case, I know in Visual C++ it's possible to select the "Executable for debug session". If you select VB there, you can start a debug session and then go to VB's IDE and run your program. Don't forget to place a breakpoint in your DLL's sources, and don't worry if VB gets frozen while you are stepping in VC++.

if I put a printf statement in the DLL C++ code, where would the output go to?

Your program should be a console executable to use a plain printf(). I guess what you need is to check some variables (to ease your debug), so let's forget that discussion. You can either use MessageBox() (enough for most cases as long as you can live with the wait-for-user-action issue) or a more "complex" API function like OutputDebugString().


Hope this helps.

How do I declare a string and pass it from a Visual Basic GUI to a C++ DLL?

Now I am debugging successfully. I can debug either on the Visual Basic end or I can debug on the C++ side by using the DLL's project file and declaring the compiled VB code as the launching executable. I have narrowed the problem down to the way that I am declaring and passiing the string variables.

Just post the current C++ function header and its respective VB declare to see what's expected on either side.

BTW, is your C++ DLL ActiveX??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.