Posted By

heislekw on 10/21/08


Tagged

error handle


Versions (?)

error handler


 / Published in: Visual Basic
 

  1. Private Sub SomeName()
  2. On Error GoTo Err_Handler
  3. ' Code to do something here.
  4. Exit_Handler:
  5. Exit Sub
  6. Err_Handler:
  7. MsgBox Err & " " & Error$
  8. Resume Exit_Handler
  9. End Sub
  10.  
  11. ' OR
  12.  
  13. Private Sub SomeName()
  14. On Error GoTo Err_Handler
  15. ' Code to do something here.
  16. Exit_Handler:
  17. Exit Sub
  18. Err_Handler:
  19. Select Case Err
  20. Case 9999
  21. Resume Next ' Use this to just ignore the line.
  22. Resume Exit_Handler ' Use this to give up on the proc.
  23. Case Else .
  24. MsgBox Err & " " & Error$
  25. Resume Exit_Handler
  26. End Select
  27. End Sub

Report this snippet  

You need to login to post a comment.