Generating Your Own Errors


Why would you want to generate your own errors? After all, you want to achieve error-free code. Sometimes it is useful when you are testing your own applications or when you want to treat a particular condition as being equivalent to a runtime error.

You can generate an error in your code with the Error statement:

 Sub Test_Error() 

Error 71

End Sub

This simulates the ‚“Drive not ready ‚½ error. You could also use Err.Raise(71) to do this. In addition, you can regenerate the current error by using the following:

 Error Err 



Excel VBA Macro Programming
Excel VBA Macro Programming
ISBN: 0072231440
EAN: 2147483647
Year: 2004
Pages: 141

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net