' Example for the Environment.Exit( Integer ) method.
Imports System
Module ExitTest
Sub Main()
Console.WriteLine( _
"If this program is invoked with [{0}] " & _
"from the command prompt,", _
Environment.CommandLine)
Dim args As String() = Environment.GetCommandLineArgs()
' args[0] is the program name, and args[1] is the first argument.
' Test for a command-line argument.
If args.Length > 1 Then
' Parse the argument. If successful, exit with the parsed code.
Try
Dim exitCode As Integer = Integer.Parse(args(1))
Console.WriteLine("it exits with code: 0x{0:X8}.", exitCode)
Environment.Exit(exitCode)
' If the parse fails, you fall out of the program.
Catch
End Try
End If
Console.WriteLine("it exits by falling through.")
End Sub 'Main
End Module 'ExitTest
' If this program is invoked with [EnvExit -2147480000] from the command prompt,
' it exits with code: 0x80000E40.