Accept Parameters in your application

T

Timothy Taylor

Hello, the following code works for VB.NET for the desktop, however it gives
me an error when i run it on the compact framework. What's the problem? Do
i have to to it differently?

Try

Dim CmdLineArgument As String

Dim separators As String = "^"

Dim commands As String = Command()

Dim args() As String = commands.Split(separators.ToCharArray)

CmdLineArgument = args(0)

MsgBox(args(0))

Catch ex As Exception

MsgBox("No Arguments")

End Try
 
A

Alex Feinman [MVP]

Simply redefine the Main sub to accept args() as String:

Sub Main(args() as String)
End Sub
 
T

Timothy Taylor

that's AWESOME! It works!

Just one question though...

It separates the parameters given to it by spaces. What if I want spaces?
How do I tell it to separate them by a "^" Character instead?

For example right now if i give the program the parameter of "Hello What's
up?" then...

args(0) has the value of "Hello"
args(1) has the value of "What's"
args(2) has the value of "up?"

I want to be able to tell it to do that for example, to do the same thing i
would have to pass it "Hello^What's^up?" otherwise it keeps it all in one
parameter of

args(0) having the value of "Hello What's up" you know?

Thanks a lot,

-Tim
 
A

Alex Feinman [MVP]

OS parses parameters in the same way as desktop version of Windows. If some
of your parameters include spaces or some special symbols, surrond them in
quotes.

myApp Hello "What's up?"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top