|
-
Mar 3rd, 2019, 06:53 PM
#1
Thread Starter
Lively Member
Is possible to import or combine C/C++ code to Visual Basic
Hi!
I began learning C.
I want to combine C code with VB, but don't know if is possible to do it with...
Combine or import or link C with VB.
For example - create GUI for C code.
Or can anybody recommend me any C/C++ editor with UI support (not only GUI, also TUI) to easier coding user interface?
Thank you for all suggestions.
Miro
-
Mar 3rd, 2019, 07:10 PM
#2
Re: Is possible to import or combine C/C++ code to Visual Basic
Hi Mirkosoft,
I find myself coding in both C and VB6. If it's a small function, it's not typically difficult to translate from C to VB6. However, for larger projects, things can be come difficult, depending on what features of C were used. Regarding combining the two, I don't believe that's going to be terribly easy. Depending on calling conventions, it's certainly possibly to call a C DLL from VB6. Also, this thread (and the link) are interesting. That Tiny C Compiler isn't very rich, but it does use the C syntax. What's somewhat sad about that Tiny C Compiler is that it doesn't support += *= etcetera operators, which is one of my favorite things about C.
Good Luck,
Elroy
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Mar 4th, 2019, 01:53 AM
#3
Re: Is possible to import or combine C/C++ code to Visual Basic
Here's my reply to your exact same question about two years ago:
 Originally Posted by Victor Bravo VI
-
Mar 4th, 2019, 03:36 AM
#4
Re: Is possible to import or combine C/C++ code to Visual Basic
You can statically link a library written in C to VB code.
-
Mar 23rd, 2019, 05:07 AM
#5
Thread Starter
Lively Member
Re: Is possible to import or combine C/C++ code to Visual Basic
Ok, I have choice:
ThunderVB
or
Runtime Tiny C Compilier for VB6
Problem is that I'm using Visual Basic 6 Portable.
So, I think ThunderVB is not possible to use, it requires installed VB6 and needs to be installed.
So, how to use Runtime Tiny C Compilier for VB6?
How to call it and even is possible to use unchanged C source?
Please explain me both choices.
I know it looks like I know near nothing, but I need it to explain to avoid mistakes which can make me frustrated.
I have also 3rd choice - Auto C possible to use like WYSIWYG GUI development in C, but there is problem with installation Microsoft ActiveX Control Pad on Windows 10 x64.
Or can anybody help me with this installation? It is best choice 'cause it's true C.
Thank you all for your support.
Miro
-
Mar 23rd, 2019, 06:26 AM
#6
Re: Is possible to import or combine C/C++ code to Visual Basic
VbRttc is very limited in the supported C language subset and is very unforgiving to even compile errors in the C sources (understandable for a 5-6KB compiler total) so it's *not* a proper choice for beginner/introductory level development.
Besides it's not a real compiler as it's compiling at run-time -- it's more like a JIT compiler.
cheers,
</wqw>
-
Mar 23rd, 2019, 08:30 AM
#7
Thread Starter
Lively Member
Re: Is possible to import or combine C/C++ code to Visual Basic
Ok, what can you recommend me to create UI for C/C++ easily?
C/C++ creating UI is far hard to do.
Miro
-
Mar 23rd, 2019, 09:46 AM
#8
Fanatic Member
Re: Is possible to import or combine C/C++ code to Visual Basic
VC 2017 Community Edition is free, but I haven't tried to make GUI with it. Your apps would require Windows 7+SP1 as a minimum to run.
If you want multi-platform, Qt and GTK seems to be the main ones, but your apps would require Vista or 7 as a minimum to run as well, unless you use an older version. I am not sure why they dropped XP, perhaps it's due theme support? I don't know, so don't quote me on that. There are GUI designers for each of these two GUI kits. I haven't used them, but I plan to pick one(possibly Qt because it runs on Android/iOS, not sure about GTK) and convert a VB6 app to it. Using VC might make me stick with Microsoft, which is what I don't want.
In my app, I am using VB6 and two DLL's, one is a standard DLL written in VC6, I use Declare statement to talk to that DLL. The other DLL is a 64-Bit COM DLL written in VC2003. Now I am facing the prospect of converting the whole thing to C++. I have customers with 700+ PC's. Asking them to upgrade all so they can use my tiny utility is not appealing.
-
Mar 23rd, 2019, 01:02 PM
#9
Re: Is possible to import or combine C/C++ code to Visual Basic
 Originally Posted by MIRKOSOFT
Ok, what can you recommend me to create UI for C/C++ easily?
In case you really want to implement and compile *everything* in C (also GUI-wise - no VB6 anywhere),
then this is perhaps the wrong forum to ask for advice.
FWIW - the tinyCC compiler really lives up to his name:
It is orders of magnitudes smaller than one of the big cannons like MingW or MS-VC (which have download-sizes, approaching 1GByte for the full "tool-chain").
The fully working C-compiler comes in a Zip smaller than 500KB: http://download.savannah.gnu.org/releases/tinycc/
(on the above selection-page, the most recent version-zips are the 0.9.27 ones - decide yourself, whether you want the 32Bit or the 64Bit-version).
As for GUI-development in C... there's no real RAD-support (meaning, no "visual Form-Designer").
All is done via C-SourceCode (even when you use a GUI-library to reduce the needed lines of code you have to write for GUI-implementations).
A good Editor (Notepad++ or similar tools) will give you syntax-highlighting and minor debugging-features though.
As for a nice GUI-support-lib for C - I can recommend IUP: https://sourceforge.net/projects/iup...aries/Dynamic/
IUP works nicely together with the tinyCC-compiler - and the coding-efforts are (thanks to a built-in Layouter) not that large...
Here's the C-Code one will have to write for a simple Demo:
Code:
#include <windows.h>
#include <iup.h>
// define the Event-callbacks for our two Buttons upfront
int btnSave_cb( Ihandle *self ){
IupMessage("IUP-Message", "Save-Dialog-Dummy-Popup");
}
int btnClose_cb( Ihandle *self ){
return IUP_CLOSE; // close the Form
}
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
IupOpen(NULL, NULL);
IupImageLibOpen();
Ihandle *label = IupLabel("\nHello world from IUP.");
Ihandle *buttonSave = IupButton("Save", NULL);
IupSetAttribute(buttonSave, "IMAGE", "IUP_FileSave");
IupSetCallback (buttonSave, "ACTION", (Icallback) btnSave_cb);
Ihandle *buttonClose = IupButton("Close", NULL);
IupSetAttribute(buttonClose, "IMAGE", "IUP_EditErase");
IupSetCallback (buttonClose, "ACTION", (Icallback) btnClose_cb);
Ihandle *vbox = IupVbox( label, buttonClose, buttonSave, NULL);
IupSetAttribute(vbox, "EXPANDCHILDREN", "YES");
IupSetAttribute(vbox, "CGAP", "5");
IupSetAttribute(vbox, "CMARGIN", "5");
Ihandle *dlg = IupDialog(vbox);
IupSetAttribute(dlg, "ICON", "APP_ICON");
IupSetAttribute(dlg, "TITLE", "Hello IUP-GUI");
IupSetAttribute(dlg, "RASTERSIZE", "320x240");
IupSetAttribute(dlg, "MINSIZE", "320x240");
IupSetAttribute(dlg, "FONT", "Arial, 10");
IupShowXY(dlg, IUP_CURRENT, IUP_CURRENT);
IupMainLoop();
IupClose();
return 0;
}
And here's the output, the above little snippet will produce:

HTH
Olaf
-
Mar 23rd, 2019, 02:22 PM
#10
Thread Starter
Lively Member
Re: Is possible to import or combine C/C++ code to Visual Basic
Hi!
Thank you for example.
But I'm not asking wrong forum - I'm programming in Visual Basic and my problem is that I have lot of C source code which I don't know to rewrite to VB and don't want to use separate GUI for executables.
I'm learning C for simple reason: To know how to convert it into VB.
I know that any WYSIWYG or Forms are not available. I need the best way to embed or combine C with VB.
No one C to VB converter works 100% bug free.
So, I asked to Auto C to better understand how to rewrite GUI - and it uses Microsoft ActiveX Control Pad - what is problem to install on Win10x64.
Miro
-
Mar 23rd, 2019, 05:36 PM
#11
Re: Is possible to import or combine C/C++ code to Visual Basic
 Originally Posted by MIRKOSOFT
I'm programming in Visual Basic and my problem is that I have lot of C source code
which I don't know to rewrite to VB and don't want to use separate GUI for executables.
Well, in that case refactor your C-Code into "functionality only, without any GUI" -
and compile it into "flat C-Dlls" (which you then use from VB via Declare Statements).
We had such a discussion here recently: http://www.vbforums.com/showthread.p...e-with-a-C-DLL
HTH
Olaf
-
Apr 22nd, 2019, 07:21 AM
#12
Thread Starter
Lively Member
Re: Is possible to import or combine C/C++ code to Visual Basic
Finally, I installed ThunderVB and partially got to work also Auto C.
Thank you for your support.
Miro
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|