The Err.Raise Method

Two situations that can possibly arise from time to time involve creating errors and simulating errors. The thought of actually creating or simulating an error seems ludicrous to the beginning programmer. Doesn’t the novice programmer already have enough errors to tackle? What situations would necessitate such decisions?

Suppose you wanted to send your user a message if a value exceeded a certain number, or suppose you wanted to test a certain error to determine the best way to handle it. In the former situation, you need to create an error.

In the latter, you need to simulate an error.

The following code creates an error message when a number exceeds a certain value. You insert a high error number so that you don’t duplicate ...

Get Access 2002 Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.