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" <an*******@disc ussions.microso ft.com> wrote in message
news:3C******** *************** ***********@mic rosoft.com...
I have the following code:
Dim MyStartupArgume nts() As String
MyStartupArgume nts = System.Environm ent.GetCommandL ineArgs
UBound(MyStartu pArguments)
RomName = (MyStartupArgum ents(0).ToStrin g)
ParentName = (MyStartupArgum ents(1).ToStrin g)
If ParentName = "" Then
LookUp = RomName
Else
Answer = Len(ParentName)
LookUp = Microsoft.Visua lBasic.Right(Pa rentName, (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