Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB + C INTEGRATION

Status
Not open for further replies.

alpeshk98

Structural
May 13, 2002
2
0
0
US
How can i integrate the programming languages.For example i have a subroutine in c program and want to add it to my VB program. I want a but to call the c-subroutine and return the values to the VB program. Can this be done ? how ?
 
Replies continue below

Recommended for you

There are *lots* of ways to integrate programming languages. You picked one of the toughest ways.

To call code written in one programming language from code written in another programming language, you have to know the following things:
1. How does each language lay out their stack? This one is REAL important. The stack is where many languages -- C is one of them -- look for:
a. variables that are passed to the subroutine
b. the return address in the calling program
2. Who is responsible for cleaning up the stack
3. How big are those variables on the stack? What is the bit order of each variable?

There are easier ways to solve this problem. Writing a file is one of them. Using pipes is another if your operating system supports pipes.

-Kevin
 
Thanx for the reply kevin but i really want to know the exactly way to connect the two. Say for example i have
1) two text boxes in VB for input
2) a button
3) a picture box to diplay output
4) a subroutine in c that takes in two number adds them a gives back a resulting variable.
Now how do i make the button pass the values from the text boxes to the subroutine and get the result variable to be displayed back in the picture box.
I want to know this becoz i have huge matrix calculation in C and its very cumbersome to re-write them in VB. Hope u have a solution for this. Thanx once again.
alpesh
 
If VB has SHELL ( command which calls other .EXE or system
commands ) you can write file SHELL to the C progran which
writes the result to a file which the C can read.
<nbucska@pcperipherals.com>
 
Status
Not open for further replies.
Back
Top