Microsoft KB Archive/45451

From BetaArchive Wiki
Knowledge Base


Article ID: 45451

Article Last Modified on 11/21/2006



APPLIES TO

  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft BASIC Professional Development System 7.0



This article was previously published under Q45451

SUMMARY

The CLEAR statement in a QuickBasic program turns off error handling routines. Any error that happens after a CLEAR statement is not trapped by an error handling routine that was initiated before the CLEAR statement. To trap errors after a CLEAR statement, you must reinstate the error handling routine with a new ON ERROR GOTO clause.

This applies to Microsoft QuickBasic Versions 3.00, 4.00, 4.00b, and 4.50, and Microsoft Basic Compiler Versions 6.00, 6.00b for MS-DOS and MS OS/2, and Microsoft Basic PDS 7.00 for MS-DOS and MS OS/2.

MORE INFORMATION

The following two programs show an error trapping routine that does not work correctly and an error trapping routine that does work:

Program 1

REM  This error handling routine will not trap the error.
  ON ERROR GOTO Handler
  CLEAR
REM The ERROR handling routine is now turned off
  ERROR 1
END
Handler: Print "In the ERROR Handler"
         RESUME
                

The output for this program is only an error message from QuickBasic.

Program 2

REM This ERROR Handling routine will trap the error.
  ON ERROR GOTO Handler
  CLEAR
REM The ERROR Handling routine is now turned off.
  ON ERROR GOTO Handler
REM The ERROR Handling routine is now turned back on.
  ERROR 1
END
Handler : Print "In the ERROR Handler"
          RESUME
                

The output for this program is as follows:

In the ERROR Handler



Additional query words: QuickBas BasicCom

Keywords: KB45451