Re: Commandline Argument Array Help
From: JLW (askme_at_someplace.com)
Date: 05/28/04
- Next message: JLW: "Re: COM wrapper around a .NET assembly"
- Previous message: Brad Allison: "Re: Deployment question"
- In reply to: jcrouse: "Commandline Argument Array Help"
- Next in thread: Herfried K. Wagner [MVP]: "Re: Commandline Argument Array Help"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 28 May 2004 14:18:19 -0400
You can go into the Assembly Properties, and under the DEBUG section, you
can tell it to pass command line args when the IDE executes the assembly.
The esiest way I've found of doing Command Line Args is use a module as your
startup and use Sub Main as follows:
Public Sub Main(ByVal args as String())
args is already a split array for you, so you can either deal with each
array member seperatly, but here's how I do it:
Public Sub Main(ByVal args as String())
Dim arg as String
For Each arg in args
Select Case arg
Case Is = "--arg1"
{put your code for Argument1 here}
Case Is = "--arg2"
{put your code for Argument2 here}
Case Is = "--help"
{put your code for commandline help here}
[Case Else 'Put this to force the use of Command Line
Switches/Arguments
{put your code for commandline help here}]
End Select
Next
End Sub
The "Case Else" is only if want the end-user to use command line swtiches.
I personally use Linux style switches, but you can easily change the "--" I
have above to "/".
HTH,
JLW
"jcrouse" <anonymous@discussions.microsoft.com> wrote in message
news:3CBA6291-7666-486F-ACDC-6064BAA07536@microsoft.com...
> I have the following code:
>
> Dim MyStartupArguments() As String
>
> MyStartupArguments = System.Environment.GetCommandLineArgs
>
> UBound(MyStartupArguments)
> RomName = (MyStartupArguments(0).ToString)
> ParentName = (MyStartupArguments(1).ToString)
>
> If ParentName = "" Then
> LookUp = RomName
> Else
> Answer = Len(ParentName)
> LookUp = Microsoft.VisualBasic.Right(ParentName, (Answer - 1))
> End If
>
> lpAppName = LookUp
>
> The problem seems to be that sometimes there is one command line argument
and sometimes there are two. If there are two, everything is alright. If
there is just one I get an error when it reads the "ParentName" line. Do I
need to somehow grab the arguments with a loop and keep checkin until
something is nell? How would I do that?
>
> Also, this is a tough program to debug in the GUI since it relies on
command line arguments. Is there a way to send commandline arguments with
the GUI for debugging so I can step through my code?
>
> Thank you,
> John
>
>
- Next message: JLW: "Re: COM wrapper around a .NET assembly"
- Previous message: Brad Allison: "Re: Deployment question"
- In reply to: jcrouse: "Commandline Argument Array Help"
- Next in thread: Herfried K. Wagner [MVP]: "Re: Commandline Argument Array Help"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|