Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Passing parameters to a VB Application

Status
Not open for further replies.

gkyriak

Programmer
Mar 19, 2002
3
US

I have 2 VB applications and I want them to interact with eachother. I normally open the second application by using the shell function. Is there any way to pass variables to the second application? I also want the second application to report back to the caller.

Any ideas?
 
You might try the following.

First - to send parameters to the other program, you would need to build the command line something like this:

dim CmdLine as String
CmdLine = "C:\MyDir\Program.exe " & Param1 & " " & Param2 & " " ....

Since Shell is actually a function, it will return a value (I believe it returns a double)

dim RetVal
RetVal = Shell(CmdLine, 1)

You can then based on the return value do what is appropriate.

Good Luck


 
Of course the program you are starting has to read the command line arguments with the function Command
 
If all you are interested in is startup parameters, the Command$ is the way to go.

But I suspect you want more than this. In fact what you seem to actually be asking is how to pass data backwards and forwards between two processes. This is actually quite a big area, and there are several solutions I can come up with off the top of my head. And I'm sure others will have other ideas.

Without going into detail (and, in particular, without discussing pros and cons), here are some thoughts:

1) Shared global memory
2) Named pipes
3) Mailslots
4) Shared, single-instance class
 

Thanks for the responses.

What I actually want to do is to send a number of string values to a number of parameters in the second application. I also want the second application to return a value back to the first one showing the result of the process (A boolean or a number).

I will try to do the things you suggested.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top