"Variable Required" Versus "Duplicate Definition" Error (42588)



The information in this article applies to:

  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.0

This article was previously published under Q42588

SUMMARY

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.

MORE INFORMATION

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.

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB42588