Home All Groups Group Topic Archive Search About

Exiting app with a code

Author
10 Jun 2009 10:25 PM
John
Hi

I have a vb.net app which used SUB Main. How can I at the end of SUB Main
exit with an exit code picked up by the app that is calling my vb.net app
exe?

Many Thanks

Regards

Author
11 Jun 2009 2:10 PM
Tom Shelton
On 2009-06-10, John <info@nospam.infovis.co.uk> wrote:
> Hi
>
> I have a vb.net app which used SUB Main. How can I at the end of SUB Main
> exit with an exit code picked up by the app that is calling my vb.net app
> exe?
>
> Many Thanks
>
> Regards
>
>

Change your Sub Main to Function Main, and then return a value:

Function Main () As Integer
  ' do a lot of really neat stuff
  Return 0 ' success?  you can return what ever you want.
End Function

Valid declaratons for Main in VB.NET:

Sub Main()
Sub Main(ByVal args() As String)
Function Main() As Integer
Function Main(ByVal args() As String) As Integer

--
Tom Shelton