954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Reading command line arguments

0
By Renan Lazarotto on Dec 26th, 2010 9:09 am

I've found this a little hard to find, so I decided to share with you guys.

This small code will allow your app to accept arguments.

Just copy the whole code into the main sub (I didn't tested elsewhere) and edit the code inside the for to do what you want. Voila! It works.

Hope it helps!

Dim CommandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String) = My.Application.CommandLineArgs

For i As Integer = 0 To CommandLineArgs.Count - 1
'the message box is just a example. you can make Ifs to check the arguments and do the desired options
MessageBox.Show(CommandLineArgs(i))
Next

Also, check out this link for a more defined explanation to using "Command Line Arguments".

codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
 

The command line argument can be shown in a messagebox like the following

msgbox(command())

anoopkh
Newbie Poster
7 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: