[RESOLVED] Getting information to process
Hi. I am new to VB.NET, prefer vb.6. I wrote a program in NET to run several console programs sequentially. That works fine. The console programs have already been written. At the end of these programs I have a MsgBox to tell me when the program is complete. When I use the new program, to execute these sequentially, the msgbox(s0 are not necessary. However, I would rather keep the option of being able to run these programs individually or from the new program. Without passing an argument to the programs, how can i determine when to execute the msgbox statements.
Thanks
Re: Getting information to process
I don't think I quite understand.
You say that you built Console Applications, which are text-only interfaces, but at the same time you say that a MsgBox (legacy holder of MessageBox) which is itself a graphical user interface widget.
Then you also say that you want to run these programs individually or through a new program without passing an option to the program to do something dynamic.
It's all too contradictory for me to understand exactly what you want. On one hand you want TUI that displays GUI and on the other hand you want to dynamically do something without specifying a condition.
It's very possible I'm misunderstanding your request, could you clarify the need a bit for me?
Re: Getting information to process
The main program has a form. I shellexecute to several console app programs. I could pass an arg, but the nI need to read an arg. That's ok. however, If I run the console app manually, then I am looking for an arg to be sent.
Re: Getting information to process
Is it that you can explain the workflow to me?
From what I understand it sounds like this:
- Running your "main program" which sounds like a Windows Form Application:
- You launch every console application sequentially
- As each one finishes, you display a message via MessageBox (or MsgBox)
- I.e. if you have 10 instances that run then you should get 10 messages each time an instance finishes
- Running your console applications as standalone applications:
- This runs as expected
- Once it's finished running, it simply closes and that's that.
Is that more or less the gist?
Re: Getting information to process
Yes. But when I run thru the launcher (form app), I don't want the msgbox(s) to show.
Re: Getting information to process
Why are you against command line arguments? Just add the ability to launch them with a argument of "silent". If that is present, don't show a msgbox. Otherwise, show a messagebox. Just because a program becomes "aware" of command line arguments doesn't mean you have to always pass arguments to the program to get it to run.
Re: Getting information to process
I was not aware then a program coded to receive a cmd line arg can run without receiving one. OK. I will do it that way.
Re: [RESOLVED] Getting information to process
That is the best suggestion. You could add something along these lines:
Code:
Public Sub Main(args As String())
Dim silentMode As Boolean = (args.Length > 0 AndAlso args.Contains("--silent"))
' do something now based on the condition
End Sub
Edit - After thinking about it, you could actually drop the length check since contains would return false anyways:
Code:
Public Sub Main(args As String())
Dim silentMode As Boolean = args.Contains("--silent")
' do something now based on the condition
End Sub
You could even make the argument case insensitive via LINQ:
Code:
Public Sub Main(args As String())
Dim silentMode As Boolean = args.Any(Function(arg) String.Equals(arg, "--silent", StringComparison.OrdinalIgnoreCase))
' do something now based on the condition
End Sub