Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
At runtime a have to send some parameters?
Posted

1 solution

Command line parameters can be handled in one of two ways:
1) You can access then in your Main function.
2) You can access them in your windows forms classes via the Application object.

If this is a console app, then use the first, otherwise use the second.

For console apps, find your Main function (it should be in the first file you created):
VB
Sub Main(Byval args() As String)
   Dim data As String = args(0)
   Console.Writeline("Argument: {0}", data)
   Console.Write("Press Enter to exit")
   Console.Read()
End Sub


For winforms, all you need to do is access Application object:
VB
For Each arg As String In My.Application.CommandLineArgs
    Console.WriteLine(arg);
Next
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900