Answered by:
Passing Variables from program to program.

Question
-
Hello,
I need help, What I'm trying to do is pass multiple variable strings from program to program. I'm not sure how to do this. I know how to pass one but not multiple.
Thank you for you help
Brock
Tuesday, May 10, 2016 2:35 AM
Answers
-
I wrote them both.
Then I suspect that the code used by davescxp in the last post in this thread How to Write an array or LIst(of) or datatable to a memory-mapped File may be of help. I don't know if there are event handlers available for the service contract so no timers are required though.
You could also use a ClipBoard listener to monitor the clipboard for changes and send messages between your programs (using the ClipBoard.Set something capability from the ClipBoard Class) for what they should do or prepare to do base on a message received or something. See - How to call App_A from App_B Guidelines? - and also there's other forms of InterProcess Communications and links in the thread for other information.
La vida loca
- Edited by Mr. Monkeyboy Tuesday, May 10, 2016 4:43 AM
- Proposed as answer by Cor Ligthert Tuesday, May 10, 2016 11:11 AM
- Marked as answer by Herro wongMicrosoft contingent staff Monday, May 23, 2016 12:35 PM
Tuesday, May 10, 2016 4:41 AM -
I wrote them both.
You could also use files in Folders and have both apps use a FileWatcher to watch their respective folders for any changes in files and if any changes occur then read the file in question.La vida loca
- Proposed as answer by Cor Ligthert Tuesday, May 10, 2016 11:11 AM
- Marked as answer by Herro wongMicrosoft contingent staff Monday, May 23, 2016 12:35 PM
Tuesday, May 10, 2016 7:10 AM -
If the applications are both running you can select from several IPC methods. One is "named pipes":
http://www.codeproject.com/Articles/16669/Asynchronous-Named-Pipes-Overlapped-IO-with-VB-NET
Paul ~~~~ Microsoft MVP (Visual Basic)
- Proposed as answer by Cor Ligthert Tuesday, May 10, 2016 9:52 PM
- Marked as answer by Herro wongMicrosoft contingent staff Monday, May 23, 2016 12:35 PM
Tuesday, May 10, 2016 6:37 PM
All replies
-
I need help, What I'm trying to do is pass multiple variable strings from program to program. I'm not sure how to do this. I know how to pass one but not multiple.
It probably depends on what you mean by 'multiple variable strings'. Multiple strings would be different than a single string only in that they include a delimiter (such as a newline character or any otherwise unused character) and that they need to be split on this delimiter in order to be processed.
If you mean that you need to pass additional strings over a period of time, then you can repeat whatever you are doing for one string.
Perhaps you should show what you are doing now, so that someone could suggest the change that is needed.
Tuesday, May 10, 2016 3:50 AM -
As an example I do this Program test Form.load Dim var1 = command() Label1.Text = var1 Program test2 Dim testString as String Process.start(appPath + "test.exe", testString) Hope this helps BrockTuesday, May 10, 2016 4:13 AM
-
Hello,
I need help, What I'm trying to do is pass multiple variable strings from program to program. I'm not sure how to do this. I know how to pass one but not multiple.
Thank you for you help
Brock
Are the programs in question programs you wrote or are you wanting to pass a string array to an external programs (program you didn't write and don't have code for) window of some type or something?
La vida loca
Tuesday, May 10, 2016 4:14 AM -
I wrote them both.Tuesday, May 10, 2016 4:16 AM
-
I wrote them both.
Then I suspect that the code used by davescxp in the last post in this thread How to Write an array or LIst(of) or datatable to a memory-mapped File may be of help. I don't know if there are event handlers available for the service contract so no timers are required though.
You could also use a ClipBoard listener to monitor the clipboard for changes and send messages between your programs (using the ClipBoard.Set something capability from the ClipBoard Class) for what they should do or prepare to do base on a message received or something. See - How to call App_A from App_B Guidelines? - and also there's other forms of InterProcess Communications and links in the thread for other information.
La vida loca
- Edited by Mr. Monkeyboy Tuesday, May 10, 2016 4:43 AM
- Proposed as answer by Cor Ligthert Tuesday, May 10, 2016 11:11 AM
- Marked as answer by Herro wongMicrosoft contingent staff Monday, May 23, 2016 12:35 PM
Tuesday, May 10, 2016 4:41 AM -
As an example I do this Program test Form.load Dim var1 = command() Label1.Text = var1 Program test2 Dim testString as String Process.start(appPath + "test.exe", testString) Hope this helps Brock
If you are invoking another application and providing a command line argument then you can use the delimited string. Simply concatenate the parts of the string using a delimiter then, in the application that retrieves the command line, use the Split method to break the string apart into its pieces. See:
https://msdn.microsoft.com/en-us/library/system.string.split%28v=vs.110%29.aspx?A comma is probably quite suitable as a delimiter, but any character that doesn't appear in the command and is legal in a command line argument would do.
But note that this method is subject to a command line length limitation.
If your concatenated strings are too long for the command line then you should write them to a file (one string per line) and pass the file name as the command line argument. The application you are opening then gets the filename from the command line, opens the file, reads the strings, closes the file, and deletes it. See:
https://msdn.microsoft.com/en-us/library/s2tte0y1(v=vs.110).aspxTuesday, May 10, 2016 5:02 AM -
I wrote them both.
You could also use files in Folders and have both apps use a FileWatcher to watch their respective folders for any changes in files and if any changes occur then read the file in question.La vida loca
- Proposed as answer by Cor Ligthert Tuesday, May 10, 2016 11:11 AM
- Marked as answer by Herro wongMicrosoft contingent staff Monday, May 23, 2016 12:35 PM
Tuesday, May 10, 2016 7:10 AM -
If the applications are both running you can select from several IPC methods. One is "named pipes":
http://www.codeproject.com/Articles/16669/Asynchronous-Named-Pipes-Overlapped-IO-with-VB-NET
Paul ~~~~ Microsoft MVP (Visual Basic)
- Proposed as answer by Cor Ligthert Tuesday, May 10, 2016 9:52 PM
- Marked as answer by Herro wongMicrosoft contingent staff Monday, May 23, 2016 12:35 PM
Tuesday, May 10, 2016 6:37 PM