Microsoft KB Archive/42588

= &quot;Variable Required&quot; Versus &quot;Duplicate Definition&quot; Error =

Article ID: 42588

Article Last Modified on 8/16/2005

-

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 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 &quot;DUPLICATE DEFINITION.&quot; 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 &quot;Variable Required&quot;, but from BC.EXE the two error messages &quot;Variable Required&quot; and &quot;NEXT WITHOUT FOR&quot; are generated.



MORE INFORMATION
The following Code will generate a &quot;Variable Required&quot; 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 &quot;Variable Required&quot; error box misleadingly gives the following run-time error explanation instead of the compile-time explanation:

&quot;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 &quot;Variable Required&quot; explained in the &quot;Microsoft QuickBasic: Programming in Basic&quot; manual for Version 4.50 is more accurate.

Additional query words: QuickBas BasicCom

Keywords: KB42588

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.