|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Console Application - Exit CodeWhat is the correct way to set the exit code from within a console
application? Currently we do: Public Function Main() As Integer ... Environment.ExitCode = ... Return Environment.ExitCode End Function Should we use Environment.ExitCode And/Or return the exit code? Thanks, Mythran "Mythran" <kip_potter@hotmail.comREMOVETRAIL> schrieb: You do not need to (and IMO should not) set 'Environment.ExitCode' if you > What is the correct way to set the exit code from within a console > application? Currently we do: > > Public Function Main() As Integer > ... > Environment.ExitCode = ... > Return Environment.ExitCode > End Function > > Should we use Environment.ExitCode And/Or return the exit code? return the exit code in the 'Main' function and vice versa. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Show quote
Hide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message After performing some tests, I found that setting Environment.ExitCode does news:OPh0NChdGHA.5016@TK2MSFTNGP04.phx.gbl... > "Mythran" <kip_potter@hotmail.comREMOVETRAIL> schrieb: >> What is the correct way to set the exit code from within a console >> application? Currently we do: >> >> Public Function Main() As Integer >> ... >> Environment.ExitCode = ... >> Return Environment.ExitCode >> End Function >> >> Should we use Environment.ExitCode And/Or return the exit code? > > You do not need to (and IMO should not) set 'Environment.ExitCode' if you > return the exit code in the 'Main' function and vice versa. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> nothing when Main is defined as a function (and hence, returns a value). If it is defined as a sub, setting ExitCode sets the exit code. So yes, you are correct :) Thanks, Mythran "Mythran" <kip_potter@hotmail.comREMOVETRAIL> schrieb: Note that VS.NET 2003 (and maybe VS 2005) didn't show the correct return > After performing some tests, I found that setting Environment.ExitCode > does nothing when Main is defined as a function (and hence, returns a > value). If it is defined as a sub, setting ExitCode sets the exit code. > So yes, you are correct :) value when running the project from within the IDE. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Show quote
Hide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message I didn't test running it in the IDE. I had a javascript that ran it and news:%23M5MKdhdGHA.1260@TK2MSFTNGP05.phx.gbl... > "Mythran" <kip_potter@hotmail.comREMOVETRAIL> schrieb: >> After performing some tests, I found that setting Environment.ExitCode >> does nothing when Main is defined as a function (and hence, returns a >> value). If it is defined as a sub, setting ExitCode sets the exit code. >> So yes, you are correct :) > > Note that VS.NET 2003 (and maybe VS 2005) didn't show the correct return > value when running the project from within the IDE. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> display the results of the Exec or Run (whichever one it was) function :) Mythran |
|||||||||||||||||||||||