Microsoft KB Archive/42588
Article ID: 42588
Article Last Modified on 8/16/2005
- 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 Q42588
When a program attempts to define a variable and a function to have the same name, an error occurs. Normally, this error is "DUPLICATE DEFINITION." However, if the variable is first used in a FOR...NEXT statement, then the error message issued from QB.EXE (or QBX.EXE under the Basic PDS 7.00) is "Variable Required", but from BC.EXE the two error messages "Variable Required" and "NEXT WITHOUT FOR" are generated.
The following Code will generate a "Variable Required" error in QB.EXE / QBX.EXE:
DECLARE FUNCTION bit% () FOR bit% = 0 TO 7 NEXT FUNCTION bit% bit% = 5 END FUNCTION
Under QuickBasic 4.50, pressing the HELP button for the "Variable Required" error box misleadingly gives the following run-time error explanation instead of the compile-time explanation:
"A GET or PUT statement must specify a variable when operating on a file opened in binary mode. ERR code: #40.
The compile-time meaning of "Variable Required" explained in the "Microsoft QuickBasic: Programming in Basic" manual for Version 4.50 is more accurate.
Additional query words: QuickBas BasicCom