I'm getting the impression this isn't possible, but here's what I've got so far.
Sub Main()
On Error GoTo ErrorHandler
If Command$ = "" Then
LogAction "Begin document lockdown"
LockdownDocs
LogAction "Lockdown complete"
Else
LogAction "Begin document enabling"
EnableDocs
LogAction "Documents have be enabled"
End If
Exit Sub
ErrorHandler:
LogAction "DocLock Error " & Err.Number & "::" & Err.Description
End Sub
I want it to look something like this:
Function Main() As Boolean
On Error GoTo ErrorHandler
If Command$ = "" Then
LogAction "Begin document lockdown"
LockdownDocs
LogAction "Lockdown complete"
Else
LogAction "Begin document enabling"
EnableDocs
LogAction "Documents have be enabled"
End If
Return True
Exit Function
ErrorHandler:
LogAction "Error " & Err.Number & "::" & Err.Description
Return False
End Function
The closest I've seen is Function Main() As Integer
in Visual Studio 2005, but I'm using VB6.
There's a possible solution here, by using a Win32 API call. In essense:
Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)
' Exit with ErrorLevel set to 9
ExitProcess 9
Note that this is the equivalent of End
to the VB runtime so you must do any cleanup, closing of connections, files, devices, forms, etc before calling ExitProcess
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With