Visual Basic and C++ - c++

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.

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).

You have some options :
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.
You can drop the idea of using Visual Basic and use C++ with a cross-platform library such as Qt.
You can drop the idea of using Visual Basic and use C++ with MFC.

Related

Why the code to write GUI application in c++ in Visual Studio is different than to console application?

I am just a begginer in c++ and I am trying to learn it for my assignment. I've been learning how to write simple console applications for past few weeks and everything was going fine, until I tried use that knowledge to write GUI application using the visual editor. I created a gui, and when I double pressed the button, the code was similar to C++ but not exactly the same.
My question is, is there any way to still use the visual editor and use the standard c++ or do I have to learn the other (visual?) c++ to make the GUI usable?
Well, you can use standard C++ (or C for that matter) to write a GUI, but you will have to use the Windows API to draw your GUIs and handle the messages that your application will receive from the operating system.
But, Visual C++ is actually helping you here in giving you a template starting point application to which you can add your specific functionality. What it generates for you is C++, although it will be heavily littered with macros &c. which does make it appear quite alien on first inspection.
That all said, I believe the cool cats use Qt these days.

Visual Basic Interface and C++ DLL

Is it a good idea to use c++ for creating DLL files and Visual basic for the windows forms? It's like Visual Basic manages all inputs and the interface while c++ takes care of all computation. Is there a big difference from creating those with Visual Basic only?
It can be a good solution to perform fast in memory operations with C++ and then use the results in .NET, we did it for an application in my previous company and it worked really well.
To make it easier to use the C++, we created a C++/CLI project wrapping the native C++ classes so we could just reference the C++/CLI project from VB.NET.

What do I need to know before switching from Qt to Visual C++?

I've been using Qt since I started to learn C++. It was the recommended SDK by professor so I didn't try another. Now that I want to learn to use Visual C++, it confuses me what the differences between those two SDKs are. I grew quite comfortable with all the signal and slot stuff of Qt. I wonder if I can find similar functionality in Visual C++. If for any chance, is there any tutorial that teaches you how to work with Visual C++?
Qt is a user interface library written in C++, available on multiple platforms; Visual C++ is a Windows IDE produced by Microsoft. They aren't really comparable -- in fact, I'm pretty sure that, if you felt like it, you could develop an application in Visual C++ which used Qt.
If what you are actually thinking of is the native Windows UI library, that's called MFC (Microsoft Framework Class). It's about 20 years old (!!) now, and contains a lot of historical quirks (including the STRING one which Neel Basu mentioned above); unless you specifically need to learn it, I would strongly recommend that you learn something else instead. If you want to learn one of Windows' native UI libraries, WinForms and WPF are more current, but are based on .NET, not C++. If you want to learn another C++ based UI library, you might want to try out wxWidgets; like Qt, wxWidgets is cross-platform.
Yes there is the Visual C++ help and the MS documentation on MFC and other component frameworks that MS provides

How to mix a VB program with a C++ Program

I have a C++ program that I wrote, and I would like to give it a user interface. Is there any way I can run a C++ program and put the information from the program onto the UI of a VB Application?
Sure.
Use
COM
COM Interop
P/Invoke (a.k.a. Declare in VB)
Oh, I forgot: C++/CLR if you intend to use Windows only
I suggest you write the whole application in a managed language (e.g. VB.Net) and only invoke C++ library functions for the performance critical work (or for legacy code that you already have, of course).
I think the easiest solution would be to put your C++ code into a DLL, and call your code from VB. Have a look at this article for more information...
http://www.codeproject.com/kb/DLL/XDllPt1.aspx
you can mix C++ and .NET
easiest is if you target your C++ code to the CLR, but you can also mix .NET and native code.
either way you basically make your C++ program a library your VB code can use.

New keywords and new type of pointers in Visual C++ 2005. What is managed C++?

Possible duplicates
What is gcnew?
What does the caret mean in C++/CLI?
Difference between managed c++ and c++
I am a advanced C++ programmer with g++. But currently I am working on Visual C++ 2005 doing Windows Forms Application programming . But I am finding it hard with its new terminology. For e.g. instead of new it has gcnew and
String ^ kind of thing. Can someone explain what is ^, similar to pointer?
Can I make Visual C++ work in the same way as normal C++ like g++ compiler? I also heard something about managed C++. What is that?
The gcnew and ^ values are managed C++ which is a different language to c++. You can use VS2005 as a normal C++ compiler by not using a project type from the CLR section of the new project window.
gcnew and ^ are from new Visual C++ syntax. The new syntax is not part of the ISO/ANSI C++ standard, but is a set of extensions to C++ standardized under the Ecma C++/CLI Standard. You can to not use them if you do not want to. Here you could read more about Visual C++ extensions.
Windows Forms are .Net specific, so you need to use C++/CLI (That's "managed C++") if you want to do those.
However, I'm not sure you really want windows forms? You just want some kind of windowy GUI, right? If that's the case you can go with something like MFC or just native O/S calls, to create your GUI, or you could use a wrapper API like Qt
[EDIT] Just to clarify a bit :)
I also heard something about managed C++. What is that?
C++/CLI is the .Net implementation of C++. Here you can use both regular C++ and managed code. C++/CLI was Microsofts attempt to ease the learning curve for C++ developers to get into the managed framework, however, it's not used a lot these days, wo you'll probably have a hard time finding (m)any good tutorials. Visual C++ is just the name of the IDE, it has nothing to do with which kind of C++ you use. You can use Visual C++ just as you use g++, but if you wan't anything over a console app, you'll need to wire some GUI logic into your application. As said in my original answer, this can be done a number of ways.
If you are sure you want to use .Net, I recommend spending a day with C#, as it's really easy to learn if you got C++ experience, but judging from your question I don't think this is what you want :)
Managed C++ is used for .Net development in the Common Language Runtime (CLR) of Microsoft. This special C++ syntax was created to allow C++ developper to come in the .Net community without learning a new language like C#.
You can use Visual C++ in the same way as g++ by creating a non-CLR project.
Note that Windows Forms are not the only way to make GUIs under Windows. You can use the regular Win32 API instead, if you want pure C (which you can wrap with C++ if you like).
If you do choose Windows Forms, then you have the option of using C#, VB.NET, or C++/CLI (Managed C++). You need not use C++/CLI, as seems to be your presumption.