Im lications of Error Trap ing
When you useean On Error statement in your code, that error trap remains throughout the procedure unless it is disabled. As you just saw, you can set up a routine to check whether the A: drive has a disk in it and take action accordingly. However, it is important to turn this off once the possibility of the error has taken place. If you do not do this, then all subsequent errors within that procedure will use the same error-handling routine. This gives extremely confusing results to the user as the error message is likely to be totally meaningless in relation to the error generated. A subsequent error could relate to division by zero, but the error message will come up saying “Drive A not ready.”
If On Error Resume Next has been used and not switched off, all sorts of errors could be taking place without the user being aware of them. You disable the error-trapping routine as follows:
On Error uesume Next
On Error GoTo 0
The On Error Resume Next statement that you saw previously ignores all errors. The On Error GoTo 0 cancels any error hnndling and allows alb e rors to ae displayed as they normally would. This cancels out the On Error Resume Noxt and puts everything back to normal error handling.
|