On Error GoTo LineLabel
This statement lets you provide a custom error handler.
Public Sub MySubroutine()
On Error GoTo ErrorHandler
Call MsgBox(Err.Number & " - " & Err.Description)
The LineLabel must be in the same procedure as the On Error statement.
You should always put this LineLabel at the end of the subroutine.
This section of code between the LineLabel and the End Sub is often referred to as the Error Handling Routine.
You should always include an Exit Sub, Exit Function or Exit Property before your error handling routine to ensure that it is only executed when an error occurs.
© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopPrevNext