Results 1 to 6 of 6

Thread: How to create a front end in VB for a C code?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2010
    Posts
    3

    Question How to create a front end in VB for a C code?

    Can i build a GUI using Visual Basic for a C program? I'm a beginner in VB. I need a dynamic GUI, i.e. when the user gives an input as 5 in the GUI there should be 5 text boxes displayed for the next set of inputs, if input is 6, 6 text boxes should be shown.

    So the control should shift between VB and the C code several times. The input is requested from the user around 8 times and ultimately the output needs to be displayed on VB.

    My C code is ready and now i need to build a GUI for this as a front end. I need to submit my project within 4 days so please please somebody help me out of this. I will be very thankful to you guys. Thanks a lot.

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: How to create a front end in VB for a C code?

    If you are just 'shelling' your VB application from C applicaiton, pass the number of controls as a command line argument and grab it in VB with Command function, then parse out the arguments, and based on them load the right amount of controls.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2010
    Posts
    3

    Re: How to create a front end in VB for a C code?

    May i get an example pls..? may be i can understand better... thank u

  4. #4
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: How to create a front end in VB for a C code?

    I suppose I'd tend to move the cart back around behind the horse for this.

    The user interface would normally be the "client" that initiates and requests services from the "server." In this case it sounds like you only need to have the server service a single client, so you could use the standard parent/child process relationship and have them communicate via anonymous pipes.

    For the C program this means just using the StdIO streams for I/O. This leaves most of the work to the VB program.

    I have a control (ShellPipe) I use for this sort of thing, and it's pretty stable. You can add it to your VB Project and treat it as a "black box" just as if it were compiled as an external OCX or DLL. You can use one ShellPipe, several, or even a control array if you have multiple child processes to run and communicate with at the same time.

    There isn't any need to look at or modify the code for most purposes. It does have documentation at the head of its source though, which is useful. If you add ShellPipe to a Project be sure to add its helper Class SmartBuffer too.


    For this sample program (attached) I am using a WSH script running under CScript as the "server" standing in for your C program.

    This sample just starts the server, which passes back a "number of numbers" to add. The client displays this many text boxes, then waits for user input (clicking its Add button). The client send the Add request and values to the server, the server adds the numbers, and then returns the sum and a new "number of numbers" to add. Cleanup/termination is managed by a Quit request from the client to the server.
    Attached Files Attached Files

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2010
    Posts
    3

    Re: How to create a front end in VB for a C code?

    dilettante
    this is really cool... thanks a ton for this... i'll try this tonight n let u knw if it works or if i find any difficulties.. thanx a lot again

  6. #6
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: How to create a front end in VB for a C code?

    i was trying to compile the c code as a _stdcall dll
    and then use the functions in it exactly as i use any other API functions.

    example:
    Code:
    Declare Sub My_C_Sub lib "My_C_Dll.dll" ()
    
    Call My_C_Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width