[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

Return Code From VB .NET Console Application?

Schorschi Decker

10/16/2002 3:44:00 AM

I know this is in the documentation some where but I can't seem to find it.
Need to return a status code when the VB .NET console application exists.
Something like Application.Exit(0) or similar method?


3 Answers

Tom Shelton

10/18/2002 2:52:00 AM

0


"Schorschi Decker" <schorschi@dslextreme.com> wrote in message
news:uqupi844b5vtb4@corp.supernews.com...
> I know this is in the documentation some where but I can't seem to find
it.
> Need to return a status code when the VB .NET console application exists.
> Something like Application.Exit(0) or similar method?
>

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

....

Return 0 ' return a value to the caller...
End Function

HTH,
Tom Shelton


Schorschi Decker

10/18/2002 4:44:00 AM

0

Does not seem to work?

VB console application still returns 0, when I return 1.

---

Public Function Main(ByVal theArgument() As String) As Integer

Return 1

End Function

"Tom Shelton" <tom@mtogden.com> wrote in message
news:uiAOnjkdCHA.2056@tkmsftngp11...
>
> "Schorschi Decker" <schorschi@dslextreme.com> wrote in message
> news:uqupi844b5vtb4@corp.supernews.com...
> > I know this is in the documentation some where but I can't seem to find
> it.
> > Need to return a status code when the VB .NET console application
exists.
> > Something like Application.Exit(0) or similar method?
> >
>
> Public Function Main(ByVal args() As String) As Integer
>
> ....
>
> Return 0 ' return a value to the caller...
> End Function
>
> HTH,
> Tom Shelton
>
>


Tom Shelton

10/18/2002 6:58:00 AM

0


"Schorschi Decker" <schorschi@dslextreme.com> wrote in message
news:uqv0svonsvl0f2@corp.supernews.com...
> Does not seem to work?
>
> VB console application still returns 0, when I return 1.

How are you retrieving the exit code? I just did a simple little test with
a console app that I shelled using the process class from another console
app - and it worked fine.

' Console App 1
Module Con1
Function Main() As Integer
Return 1
End Function
End Module


' Console App 2
Module Con2
Sub Main()
Dim p As New Process()
p.StartInfo.FileName = "consoleapplication6.exe"
p.Start()
p.WaitForExit()
Console.WriteLine(p.ExitCode)
Console.ReadLine()
End Sub
End Module

Tom Shelton