Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

linking languages

Options
  • 06-03-2006 7:36pm
    #1
    Closed Accounts Posts: 18


    does anybody know if it is possible if it is possible to link c code behind a vb interface? you see i wana use a button in vb that programs a microcontroller through the serial port in c

    ty


Comments

  • Moderators, Music Moderators Posts: 23,361 Mod ✭✭✭✭feylya


    Well, you could make the C program accept command line options and then each button in the VB interface calls a shell command with the appropriate option.


  • Registered Users Posts: 515 ✭✭✭NeverSayDie


    Or use a DLL with your functions written in C, import it and call them from VB.


  • Closed Accounts Posts: 18 suzie06


    Thanks lads

    I am a newbie to this so which way would you think would be the easiest? also is there any help or tutorials on this stuff. i have a vb interface layed out and i want to program my pic through c using mscomm

    ty


  • Closed Accounts Posts: 18 suzie06


    Thanks lads

    I am a newbie to this so which way would you think would be the easiest? also is there any help or tutorials on this stuff. i have a vb interface layed out and i want to program my pic through c using mscomm

    ty


  • Closed Accounts Posts: 18 suzie06


    Thank you NeverSaydie

    I have a program in c, how can i make a dll from it? would i use the shell command to call the program then??

    thank you for your patience


  • Advertisement
  • Registered Users Posts: 515 ✭✭✭NeverSayDie


    No, you don't need to use the shell, basically, your C/C++ DLL exports whatever functions you want to make available, you can then import them in VB, and call them more or less like regular functions.

    This set of tutorials should give you some info;
    http://www.codeproject.com/dll/XDllPt1.asp

    There's lots of tutorials on the topic out there, just Google for it, should turn up loads.


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    suzie06 wrote:
    does anybody know if it is possible if it is possible to link c code behind a vb interface? you see i wana use a button in vb that programs a microcontroller through the serial port in c

    ty

    So what you want to do is program a serial port in VB.

    What you send across that serial port has nothing to do with Visual Basic. As far as VB is concerned, its just data. Perhaps its binary, perhaps its ascii, but all it is is data.

    You may also want VB to do some other stuff before it talks to the serial port, (like the compiling/linking/assembling). For this, what you want is to get VB to talk to a compiler/linker/assembler and tell it what to do. Again, what the compiler/linker/assembler handles has nothing to do with VB. Its just gonna pass parameters (like a filename) to the program in question, to tell it what to do.

    So I don't think teh question has anything to do with VB & C. It has to do with :

    1) How can VB control a serial port
    2) How can VB control external programs.

    The answer to question 2 is Shell. There are other possibilities, but until you can say why Shell doesn't do what you want, Shell is what you want.

    The answer to question 1...IIRC there's a control built in to VB for controlling Serial Ports. Google or even a search of hte helpfile for "Visual Basic Serial Port" should answer that.


  • Registered Users Posts: 362 ✭✭theone


    I'm doin a similar project meself communicating with the serial port I'm doing it through c# though, It's alot easier to do it just in vb instead of linking c nd vb together as was mentioned before.
    This link is pretty useful for what you are trying to do,

    http://www.htservices.com/Tools/VBandC/SerialCommunications.htm

    I used this one http://msdn.microsoft.com/msdnmag/issues/02/10/netserialcomm/ and modified it to suit you don't have to use p invoke anymore though .net 2 deals with it directly whereas 1.1 didn't.


  • Closed Accounts Posts: 884 ✭✭✭NutJob


    Could you post a full spec as im very confused

    theres now 3 threads with the same question and alot of confustion. Well at least im confused.


    -Do u want to control a c compiler
    -A serial port

    -Is it a test of calling c proceadures in a dll using vb

    If anything without a full spec and details any advice will add to the confusion

    am i think :confused:


  • Closed Accounts Posts: 18 suzie06


    it is a test of calling c proceadures in a dll using vb

    cheers


  • Advertisement
  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    did you not check the VB manual/help files? It is very well documented on how to call C++ APIs.


Advertisement