Thread: C++ & VB

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    719

    C++ & Vb

    obviously i'd like to use VB as my front end and c++ on the back end. but i can't seem to find any resources on how to do this. i'm guessing i need to create a dll with c++ and then import it in VB. is this correct? what else do i need to do? and do you know of any online resources which may help?

    edit: and how do i import a dll in VB? does this involve code or just telling the linker what to add in?
    Last edited by misplaced; 01-10-2005 at 05:43 AM.
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  2. #2
    Registered User
    Join Date
    Dec 2004
    Posts
    95
    You can write your DLL with C linkage and then use the exported functions from VB like you do Windows API functions.

    Or you can write an ActiveX (COM) DLL and use it from VB in the normal way.

    The first method is straightforward, basically make your exported functions __stdcall and extern C, and export via a .def, then write a bas module in VB to declare your functions and data types in VB.

    The second is nicer wrt the VB programmer, though perhaps not the C++ programmer unless you're familiar with COM (and even then COM isn't fun).

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    ATL is a great help for the second method.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    It depends on what you define as "front-end" and "back-end".

    Why not use MFC for the lot? A lot of GUI stuff is almost as easy as VB, and you get to use C++ for the nitty-gritty. Oh, and you have some nice COM & ActiveX tools if you need some of the features and controls that you use in VB.

  5. #5
    Registered User
    Join Date
    Dec 2004
    Posts
    95
    I'd say there's a fair difference between easy of GUI creation in VB and in MFC. The VB6 form designer is very nice for quick and easy GUI creation. Plus MFC makes people shudder (but then so does VB..).

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    It's only difficult if you dont know it. For a simple form with basic controls (a basic front end) it's as quick in MFC as in VB if you know both tools pretty well.

  7. #7
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    Quote Originally Posted by Fordy
    It's only difficult if you dont know it. For a simple form with basic controls (a basic front end) it's as quick in MFC as in VB if you know both tools pretty well.

    i would much rather use VB. i've never really used it before and i just installed and opened it, put a button on a form and made it dissappear when it was clicked in about 45 seconds with one line of code without even reading any documentation. granted it's completely useless, but even with MFC that would take no less than, oh, 15-20 lines of code.


    edit: i am the king of run on sentences
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  8. #8
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    [picky]

    >>but even with MFC that would take no less than, oh, 15-20 lines of code.

    actually not realy.....

    With the MFC editor you would only have to WRITE one line in the code created. After adding all the other stuff.

    (that line being m_Button.ShowWindow(SW_HIDE); )

    Still VB is easier (but l like to heavily customise my controls/dlgs and so prefer MFC / WIN32.)

    In pure WIN32 allow a few hours and a hundred or so lines.

    [/picky]
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

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