0

I wanting to add Command Line Arguments to my VB.Net project. Basically I want to pass my program a file path and a number (5 digits) which will then be assigned to 2 separate strings variables on form load. If either of these are not passed then an additional form is opened asking to locate the missing variables.

I know how to call the program with parameters using Process.Start but can't work adding the requirement to the loading project.

I have looked at lots of info on the web regarding this but cant make much sense, can anyone point me in the right direction

Thanks

elmonko
  • 665
  • 2
  • 12
  • 29
  • heres [how to start the app without a form](http://stackoverflow.com/a/25554057/1070452). This would allow you to process the commandline and call the missing args form only if there are some missing; then call the main form – Ňɏssa Pøngjǣrdenlarp Sep 20 '14 at 01:08

1 Answers1

1

Here is one way to do it:

For Each argument As String In My.Application.CommandLineArgs
  ' iterate through your arguments and make sure they passed as expected.
Next

References:

Last time I looked at it (not this, but a similar method), there was a problem with how arguments are parsed, and may be causing unexpected behavior in certain cases. Most of time you will not notice, but it's best to be prepared when it happens, check the article I wrote last year:

Victor Zakharov
  • 25,801
  • 18
  • 85
  • 151