You can get a message box that looks very much like a standard error message by placing it in the "Else" block:
MsgBox "Run-time error '" & Err.Number & "':" & _ vbNewLine & vbNewLine & _ Error(Err.Number), vbExclamation + vbOKOnly, _ "YourProjectNameHere"
But this is just a facsimile. This is not the actual error message dialog box that VB6 hosts; it is simply formatted to look like this. Error handling is still disabled by the "Enable error after completion" statement at this point.
But if you really, really want to call the standard error handling code, you can put it in the "Else" block:
Dim SaveError As Long SaveError = Err.Number On Error Goto 0 Error (SaveError)
This code stores the error number, enables error handling again, and then re-generates the error. This way you invoke the VB real-time error processing machines. But be careful: if this error is not caught with the active error handler somewhere higher in the call chain, it will terminate your program after the user clicks the OK button.
Note that you will also lose the ability to get the actual line number where the error occurs using "Erl" in this error handler, because you are re-generating the runtime error using the "Error (SaveError)" instruction. But that probably doesn't matter, because most VB code doesn't actually use line numbers, so Erl just returns 0 anyway.
Jeffk source share