Accept Parameters in your application

  • Thread starter Thread starter Timothy Taylor
  • Start date Start date
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
 
Simply redefine the Main sub to accept args() as String:

Sub Main(args() as String)
End Sub
 
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
 
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?"
 
Back
Top