Advertisement
Guest User

Untitled

a guest
Jun 30th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. Sub Test()
  2. On Error Resume Next
  3. Dim O1 As New Class1
  4. O1.DoSomething
  5. On Error GoTo 0
  6. End Sub
  7.  
  8. Sub DoSomething()
  9. FindStuff
  10.  
  11. 'create similar objects who perform similar operations and raise similar errors
  12. Dim O2 As New Class2
  13. O2.DoSomething
  14. End Sub
  15.  
  16. Function FindStuff() As Stuff
  17. 'scan the WorkBook, the file system, etc. and organize the members of the object
  18. If CorruptedFileSystem Then Err.Raise 514, "File system corrupted"
  19. If CorruptedWorkBook Then Err.Raise 515, "WorkBook corrupted"
  20. If Found Then Set FindStuff = FoundStuff
  21. End Function
  22.  
  23. Sub Test1()
  24. Dim O As New Class1
  25. O.UnhandledCall
  26. End Sub
  27.  
  28. Sub Test2()
  29. On Error Resume Next
  30. Debug.Print 1 / 0
  31. Dim O As New Class1
  32. O.HandledCall
  33. On Error GoTo 0
  34. End Sub
  35.  
  36. Sub UnhandledCall()
  37. Debug.Print 2 / 0
  38. End Sub
  39.  
  40. Sub HandledCall()
  41. Debug.Print 3 / 0
  42. End Sub
  43.  
  44. Sub Test()
  45. Dim foo As Class1
  46. Set foo = New Class1
  47. 'On Error Resume Next
  48. foo.DoSomething
  49. 'On Error GoTo 0
  50. End Sub
  51.  
  52. Sub DoSomething()
  53. Err.Raise 5
  54. End Sub
  55.  
  56. If CorruptedFileSystem Then Err.Raise 514, "File system corrupted"
  57. If CorruptedWorkBook Then Err.Raise 515, "WorkBook corrupted"
  58.  
  59. If CorruptedFileSystem Then Err.Raise 514, "Class1.DoSomething", "File system corrupted"
  60. If CorruptedWorkBook Then Err.Raise 515, "Class1.DoSomething", "Workbook corrupted"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement