HOWTO: Set an Error Level from a Visual Basic Application |
Q178357
This article contains a sample Visual Basic application that sets the error level upon exiting and a DOS batch file to test the result. Visual Basic applications can also retrieve the error level returned by another Windows application using the technique shown in Q129796 listed below.
Private Declare Sub ExitProcess Lib "kernel32" _
(ByVal uExitCode As Long)
Private lExitCode As Long
Private Sub Command1_Click()
lExitCode = 50& 'Button labeled "50"
Unload Me
End Sub
Private Sub Command2_Click()
lExitCode = 100& 'Button labeled "100"
Unload Me
End Sub
Private Sub Command3_Click()
lExitCode = 150& 'Button labeled "150"
Unload Me
End Sub
Private Sub Form_Load()
Command1.Caption = "50"
Command2.Caption = "100"
Command3.Caption = "150"
End Sub
Private Sub Form_Terminate()
' Call ExitProcess as the last action before closing
' otherwise it prevents proper clean up
ExitProcess lExitCode
End Sub
echo off
start /w project1
rem "start /w"
if errorlevel 150 goto 150
if errorlevel 100 goto 100
if errorlevel 50 goto 50
echo Exit Code 0
goto Done
:150
echo Exit Code 150
goto done
:100
echo Exit Code 100
goto done
:50
echo Exit Code 50
:done
echo done
Q129796 : HOWTO: 32-Bit App Can Determine When a Shelled Process Ends
Additional query words:
Keywords : kbVBp400 kbVBp500 kbVBp600 kbGrpDSVBDB kbDSupport
Issue type : kbhowto
Technology :
|
Last Reviewed: February 22, 2001 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |