Home All Groups Group Topic Archive Search About

Reading an argument given to the program when started

Author
31 Mar 2006 11:31 AM
Joris De Groote
Hi

I am busy trying to create a VB.NET program. I want to give the program an
argument in the shortcut I created for that program (for example:
program.exe argument).
Now I just can't find how I can read that argument in my VB.NET program.

Can anyone help me?

Thanks
Joris

Author
31 Mar 2006 3:18 PM
Claes Bergefall
Try Environment.GetCommandLineArgs or Environment.CommandLine

  /claes


Show quoteHide quote
"Joris De Groote" <joris.degro***@skynet.be> wrote in message
news:euQYtaLVGHA.6084@TK2MSFTNGP14.phx.gbl...
> Hi
>
> I am busy trying to create a VB.NET program. I want to give the program an
> argument in the shortcut I created for that program (for example:
> program.exe argument).
> Now I just can't find how I can read that argument in my VB.NET program.
>
> Can anyone help me?
>
> Thanks
> Joris
>
Author
31 Mar 2006 3:23 PM
AlanT
public class MyProgram


public shared Sub Main(args() as string)

   'args contains an array of strings representing the command line


   dim mainForm as new MyForm(args)

   Application.Run(mainForm)


end


hth,
Alan