4
我得到的印象是不可能的,但這是迄今爲止我所得到的。VB6 exe的返回值Main?
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
我見過的最接近的是在Visual Studio 2005 Function Main() As Integer
,但我使用VB6。
+1 - 相當聰明,不知道'ExitProcess' – LittleBobbyTables 2012-07-16 20:57:29
美麗,優雅的解決方案。非常感謝! – 2012-07-16 21:19:07
+1,但要確保你已經完成了所有清理工作,關閉並釋放所有對象,將所有對象設置爲'Nothing'等, – Deanna 2012-07-17 19:26:56