How to recognize a Command Line parameter?

A

Anil Gupte

I am trying to send a command line parameter to a utilty I wrote. For
example:

c:\utilities\powerbuddy.exe 50

The 50 can be any number.

How do I see it in the program? Do I have to create a Main rountine and
pass it the value? If so how? And then, how do I load the main form of the
applicaiton from the Main sub?

Thanx,
 
H

Herfried K. Wagner [MVP]

Anil Gupte said:
I am trying to send a command line parameter to a utilty I wrote. For
example:

c:\utilities\powerbuddy.exe 50

The 50 can be any number.

How do I see it in the program? Do I have to create a Main rountine and
pass it the value? If so how? And then, how do I load the main form of
the applicaiton from the Main sub?

<URL:http://groups.google.de/group/microsoft.public.dotnet.languages.vb/msg/95ee4737bce72df5>

Loading the form:

\\\
Application.Run(New MainForm())
///
 
A

Anil Gupte

I am getting No accessible 'Main' method with an appropriate signature was
found in 'PowerBuddy'.

Where do I put this:
Public Module Program

Public Sub Main(ByVal Arg As Integer)

End Sub

End Module

I right clicked on the solution and picked "Add Module". Then I added the
Sub Main and made the module Public. Still I am getting the abvoe error.

Thanx,
 
H

Herfried K. Wagner [MVP]

Anil Gupte said:
I am getting No accessible 'Main' method with an appropriate signature was
found in 'PowerBuddy'.

Where do I put this:
Public Module Program

Public Sub Main(ByVal Arg As Integer)

The 'Main' sub expects an array of strings as shown in my sample. You'll
have to perform your own conversion:

\\\
Public Sub Main(ByVal Args() As String)
Dim Number As Integer
If Args.Length > 0 Then
Number = CInt(Args(0))
Else
...
End If
End Sub
///
 

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

Top