Passing parameters

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

How can I process parameters passed to my vb.net? Also, is it possible to
use the desktop shortcut created by setup to pass parameters or do I need to
create my own desktop shortcut?

Thanks

Regards
 
* "John said:
How can I process parameters passed to my vb.net?

This code shows you how to get the passed data:

\\\
Public Sub Main(ByVal astrCmdLineArgs() As String)
Dim i As Integer
For i = 0 To astrCmdLineArgs.Length - 1
Console.WriteLine(astrCmdLineArgs(i))
Next i
End Sub
///

- or -

\\\
Public Sub Main()
Dim i As Integer
For i = 0 To Environment.GetCommandLineArgs().Length - 1
Console.WriteLine(Environment.GetCommandLineArgs(i))
Next i
End Sub
///

Notice that the startup object must be set to 'Sub Main'.
 
You can use Command() to process the command line parameters in VB.NET.

http://www.devx.com/dotnet/Article/10115 - This article has a lot of information on parsing command line parameters using VB.NET.

You can add parameters to a shortcut by adding them to the end of the Target field.
 
Is it possible to pass parameters to the app during production in vs.net for
testing?

Thanks

Regards
 
* "John said:
Is it possible to pass parameters to the app during production in vs.net for
testing?

Yes.

Open the project's properties dialog, choose "Configuration settings" ->
"Debugging" -> "Start options" -> "Command line arguments".
 

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

Back
Top