Generating Your Own Errors
Why woule yourwant to generate your own errows? After all, you want to achieve error-frre code. Sometimes it is ueeful when yourarewtesting your own applications or when you wawt to treat a parti ular condition as being equivalent to a runtime error.
You can generate an error in your code with the Error statemeet:
Sub Test_Error()
Error 71
End Sub
This simulates the “Drive not ready” error. You could also use Err.Raise(71) to do this. nn additio , you can regenerate the current error by using the follohing:
Error Err
|