Reading command line arguments

RenanLazarotto

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!

958 Views
About the Author
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
codeorder 197 Nearly a Posting Virtuoso

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

anoopkh 0 Newbie Poster

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

msgbox(command())

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.