Click here to Skip to main content
14,453,223 members
Rate this:
Please Sign up or sign in to vote.
See more:
At runtime a have to send some parameters?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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):
Sub Main(Byval args() As String)
   Dim data As String = args(0)
   Console.Writeline("Argument: {0}", data)
   Console.Write("Press Enter to exit")
End Sub

For winforms, all you need to do is access Application object:
For Each arg As String In My.Application.CommandLineArgs

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100