我的印象是这是不可能的,但这就是我到目前为止所得到的。
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
我希望它看起来像这样:
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
我见过的最接近的是Function Main() As Integer
Visual Studio 2005,但我使用的是 VB6。