Here is an example of a useful on error resume next:
Private Function HasElements(ArrayIn As Variant) As Boolean
'this routine will test to see if a 1d array is initialized
On Error Resume Next
HasElements = (UBound(ArrayIn) >= LBound(ArrayIn))
End Function
Typically, this is what I do:
Private Sub foo()
On Error GoTo foo_Error
'work goes here
ExitHere:
'clean up code goes here
On Error GoTo 0
Exit Sub
foo_Error:
'log the error here by inspecting the Err object
Resume ExitHere
End Sub
Say you where in a loop and you wanted to catch an error in the loop, you could use the above construct with the resume next command, that would place you on the next line following the error.
Here is an example:
'This routine takes a csv string if line handles and returns a collection
'of acadLine's
Private Function stringToHoles(sCol As String, sIdentifier As String) As Collection
Dim lineObj As AcadLine
Dim sHandles() As String
Dim i As Long, upper As Long
Dim colLines As New Collection
On Error GoTo ErrorHandler
If Len(sCol) = 0 Then GoTo ExitHere
sHandles= Split(sCol, ",")
upper = UBound(sTemp)
For i = 0 To upper
Set lineObj = ThisDrawing.HandleToObject(sHandles(i)) 'this will cause an error if the handle doesn't exist
If Not lineObj Is Nothing Then
lineobj.Highlight True
colLines.Add lineobj
End If
Set lineObj = Nothing
Next i
Set stringToHoleCollections = colLines
ExitHere:
Set colTemp = Nothing
Erase sTemp
On Error GoTo 0
Exit Function
ErrorHandler:
Select Case Err.Number
Case -2147467259 'Automation error Unspecified error - Means the object doesn't exist
Set lineObj = Nothing
Resume Next
Case -2145386484 'unknown handle - means the handle doesn't exist in the drawing
Set lineObj = Nothing
Resume Next
Case -2145386420 'object erased continue on
Set lineObj = Nothing
Resume Next
Case Else
End Select
Resume ExitHere
End Function