Reading command line arguments

RenanLazarotto 0 Tallied Votes 1K Views Share

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
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


Be a part of the DaniWeb community

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