BC.EXE Subprogram Error Occurs in ERROR GOTO in SELECT CASE (30403)






This article was previously published under Q30403

SYMPTOMS

Placing an ON ERROR GOTO statement in a SELECT CASE statement inside of a subprogram (SUB...END SUB) procedure will generate the message "Subprogram error," which is a compile-time error.

STATUS

Microsoft has confirmed this to be a bug in QuickBasic Versions 4.00, 4.00b, and 4.50, and in Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS and OS/2 (buglist6.00, buglist6.00b). This problem was corrected in Microsoft Basic Compiler Version 7.00 (fixlist7.00).

MORE INFORMATION

This error does not occur in the QB.EXE environment or if the SELECT CASE statement is located in the main module.

The following is a code example:
   DECLARE SUB testsub ()
   CALL testsub
   END

   errortrap:
   END

   SUB testsub
     i% = 1
     SELECT CASE i%
        CASE 1
            ON ERROR GOTO errortrap
        CASE ELSE
     END SELECT
   END SUB
				
The following is the output of the compile from BC.EXE:
   Microsoft (R) QuickBasic Compiler Version 4.00B
   Copyright (C) Microsoft Corp. 1982-1988. All rights reserved.
    006B   0006         CASE ELSE
                        ^ Subprogram error

   43108 Bytes Available
   42683 Bytes Free

       0 Warning Error(s)
       1 Severe  Error(s)
				

Modification Type: Minor Last Reviewed: 1/8/2003
Keywords: KB30403