Error handling

In all subs and function you should use a error handler. This error handler catches errors and allow you to show the error and stops the Vba from breaking down.

Code example

Private Sub GetValue()
On Error GoTo ErrorHandler
    'Write your code
Exit Sub
ErrorHandler:
    Call UI.ShowError(“Actionpad_Company.GetValue”)
End Sub

To avoid errors to even happen it could be a good thing to check for general errors.

Use If statements to avoid using objects that is Nothing

If Not oMyObject Is Nothing Then
    ' Do my magic stuff with the object
Else
    Call Lime.MessageBox("Message to user")
End If
  • Last modified: 5 years ago
  • (external edit)