Thread: C++ to VB?

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    184

    C++ to VB?

    I have a good question. Can anybody tell me how I can call a Visual Basic program from a C or C++ program and possibly pass parameters with it? The reason being is that it seems to me that it is so much easier to design windows programs with VB than C++ and it would be a lot quicker. I would like to use VB for all my windows and C++ for the functionality and the backbone of the system. Any suggestions????

    Thanks,
    Kendal

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    I know its possible to call DLL's written in visual basic from a c++ program but I have no experience of how this is set up. Maybe there is an article or two at MSDN
    Its easy enough to use c++ to make your windows rather than visual basic. C++ will also perform better than visual basic but if thats what you are comfortable with then MSDN is your best reference.
    Failing that try asking your question on the forums at Programmers heaven.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    The other way 'round???

    Your VB program is probably going to be the main program that calls DLLs written in C++. This is because windows applications run in a continuous loop waiting for "messages" (mouse & keyboard input) from the operating system.

    I've never used VB, but it's my understanding that it much easier than Visual C++. I've been told that you "drag and drop" buttons & menus, etc.

    I assume that this is a temporary solution as you are learning C++ to make your programs "look better". Otherwise, it would be better to code the entire program in the same language.

  4. #4
    Registered User
    Join Date
    Feb 2003
    Posts
    184

    The Situation

    The situation is, me and my coworkers are trying to design a Medical Records system. We are working on phase 1 right now. Phase 1 is a command line interface written in DJGPP. What I have to do right now is to figure out a way to interface a program I will write in Dev-C++ or Visual C++(Have not figured out which would be better, trying to get by with Dev since it is free), with the DJGPP program to accept a filename parameter and display that file. The file will be a scanned in image; jpg, tif, bmp, possibly text also. I will eventually have to work on converting the whole system into a windows format, but for now I need to display images passed from DJGPP. I know it is a lot, but anyone with any advice???

    Sincerely grateful,
    Kendal

  5. #5
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    CreateProcess() is the API call to launch an app. There you can pass your command line parameters

    in VB the command line I don't know about
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  6. #6
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    Thoughts and vague suggestions...

    If you mix C++ and Visual Basic, your program will be harder to upgrade and maintain.

    Experiment with both languages. (You would have to buy Visual Basic.) Write a program in both that opens and dislays a bitmap. You could use one language, and one of your coworkers could use the other. My guess is that Visual Basic will "win". My boss seems to whip-out VB programs much more quickly than I could write a C++ Windows App. (Neither of us are full-time programmers; We're hardware guys. We both know command-line basic, I don't know Visual Basic, and he doesn't know C.)

    Do some research to find out the difficulty of converting/handling the various file formats in each language. Any "visual" or windows compiler will have functions for bitmaps. If you find a compiler that has a built-in library for handling the various image formats, you'll save lots to time!

    This a C++ board so there may be some bias.

  7. #7
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    (***) Make your whole program in the same language, it's easier no matter which language you choose! (***)

    Well, making a GUI program in C++ is not a lot of fun. If you are pressed for time, which most work projects are, you have close to no chance on learning how to make a GUI in C++. VB is much easier for that but it's much slower. I suggest you use either:

    A) Java
    - There are a lot of free GUI tools out there
    - Moderatly fast with a JIT
    - Almost the same syntax as C++

    B) C#/VB.NET
    - Super easy to learn and develop
    - C# has the almost same syntax as C++
    - Only ~10% slower than the best C++ code you can possibly make
    - FREE! Instead of paying for the whole IDE (which is the best; its RAD tool just like VB6), you can download the free compilers from www.microsoft.com

    C) Buy a book on MFC
    - Have fun learning Windows GUI for C++ (not really, lol)

    PS: For VB to execute a program, use the Shell(CommandLine as String) Function.
    PSS: To find the command line parameters from VB, its a little tricky. Just do a search at www.planet-source-code.com There are a few examples there in the VB section.
    Last edited by Speedy5; 02-25-2003 at 10:03 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing an Array of Strings from VB to a C DLL
    By mr_nice! in forum Windows Programming
    Replies: 9
    Last Post: 03-08-2005, 06:16 AM
  2. C with VB ?
    By khpuce in forum Windows Programming
    Replies: 2
    Last Post: 02-21-2005, 08:00 AM
  3. Passing parameters from VB to C++ through ActiveX DLL
    By torbjorn in forum Windows Programming
    Replies: 0
    Last Post: 12-10-2002, 03:13 AM
  4. VB Calling Convention?!
    By minime6696 in forum Windows Programming
    Replies: 6
    Last Post: 03-27-2002, 04:39 PM
  5. Sending a string to C++ from VB 6.
    By VirtualAce in forum C++ Programming
    Replies: 4
    Last Post: 08-21-2001, 02:28 AM