command line arguments

J

James

vb.net 2003

i created console.exe file and from cmd prompt i would like to pass
arguments into it.

Eg myprogram.exe ntid

myprogram.exe expects to read a variable enter by user. How do i pass
arguments to be read by my program ? The below only display it and not
reading a variable

Dim arguments As [String]() = Environment.GetCommandLineArgs()

Console.WriteLine("GetCommandLineArgs: {0}", [String].Join(", ", arguments))
 
H

Herfried K. Wagner [MVP]

James said:
i created console.exe file and from cmd prompt i would like to pass
arguments into it.

Eg myprogram.exe ntid

myprogram.exe expects to read a variable enter by user. How do i pass
arguments to be read by my program ? The below only display it and not
reading a variable

What do you mean by "reading a variable"?!
 
P

Phill. W

i created console.exe file and from cmd prompt i would like to pass
arguments into it.

Eg myprogram.exe ntid

Try this :

Public Argument1 as String = Nothing

Function Main( ByVal saArgs as String() ) as Integer
Argument1 = saArgs( 0 )
. . .
End Function

HTH,
Phill W.
 
C

Crouchie1998

Main is a sub so why declare it as a function?

Crouchie1998
BA (HONS) MCP MCSE
 
T

The Grim Reaper

I believe, it's so that the Main function can return a value to the calling
process/DOS window/whatever ran the exe...
____________________________________
The Grim Reaper
 
H

Herfried K. Wagner [MVP]

The Grim Reaper said:
I believe, it's so that the Main function can return a value to the calling
process/DOS window/whatever ran the exe...

That's true.
 

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