vb6error-handling

Difference between Resume and Goto in error handling block


I understand that in the following example a Resume statement should be used instead of a Goto statement.

Sub Method()
  On Error Goto ErrorHandler
  ...
CleanUp:
  ...
  Exit Function

ErrorHandler:
  Log error etc

  Err.Clear  'Is this line actually necessary?'

  Resume CleanUp 'SHOULD USE THIS'
  Goto CleanUp  'SHOULD NOT USE THIS'
End Sub

My question is what difference is there in the execution of the two?


Solution

  • Both transfer execution to the Cleanup label. As far as I can remember, the only differences are

    The VB6 manual entry for the Resume statement doesn't explain these differences.