command line arguments in vb

rutledgj used Ask the Experts™
dumb and simple question. I've created a console app and want to read in command line arguements.  Main looks like this:

 Dim s() As String = System.Environment.GetCommandLineArgs()

        For i As Integer = 1 To UBound(s)
            Console.WriteLine(s(i) & vbCrLf)


in properties/debugger I'm passing in this:


when I run it s(1) contains the entire list of words. I expected each word to be in its own array position.

Can someone tell me what I'm doing wrong here?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Try using the My.Application.CommandLineArgs property instead, it is a collection of arguments tokenized by whitespace like you are expecting.
The delimiter is a space.

Hello world you are cruel has 5

or "hello" "world" "you are cruel" has 3
The first is always the name of the program.
Oh sorry I misread you.

The reason why you are seeing the command line arguments all in one shot is because command line arguments are tokenized by *whitespace*, not by commas.

So when you put in the arguments


There is no whitespace in that line, so it is considered to only be one argument. This is the behavior for all applications in Windows. If you wanted to accept command line arguments in that format you'd ned to parse it by comma yourself.

You probably meant to do this:

"hello" "world" "you" "are" "cruel"

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial