Microsoft KB Archive/39378

= &quot;Formal Parameter Specification Illegal&quot; for DECLARE Variable =

Article ID: 39378

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

-



This article was previously published under Q39378



SUMMARY
The BC.EXE compiler generates a &quot;Formal parameter specification illegal&quot; error when a DECLARE statement uses a variable that is the same name as a FUNCTION or SUB previously declared in the program. The QB.EXE editor will not generate an error for the same DECLARE statement.

In general, you should never have any variables with the same name as any other identifier in your programs. You should also avoid having any two variables or identifiers that only differ by the data type specifier. For example A$ and A% are poor choices for variable names in the same program.



MORE INFORMATION
The DECLARE statement is only used as a prototype for checking the number and types of the arguments used to invoke the procedures, and it affects the entire module. The type of the variables can be INTEGER, LONG, SINGLE, DOUBLE, STRING, or a user-defined type. Fixed-length strings (STRING*n) cannot be used in a DECLARE statement, because only variable-length strings can be passed to SUB and FUNCTION procedures.

More information about the DECLARE statement can be found in the &quot;Microsoft QuickBasic: Basic Language Reference&quot; manual (on pages 139-146 for QuickBasic Versions 4.00 and 4.00b; pages 55-56, 271, 299, and 332- 333 for QuickBasic Version 4.50; and pages 139-146 for Basic Compiler Versions 6.00, and 6.00b).

The following is a code example: DECLARE FUNCTION test% (Num%) DECLARE SUB ShowTest (test%)  ' This will generate an error A = test%(10) ShowTest (A) END

SUB ShowTest (Var%) PRINT Var% END SUB

FUNCTION test% (Num%) test% = Num% END FUNCTION The following error is generated for the above program:

Microsoft (R) QuickBasic Compiler Version 4.50

(C) Copyright Microsoft Corporation 1982-1988.

All rights reserved.

Simultaneously published in the U.S. and Canada.

0030 0006 DECLARE SUB ShowTest (test%)

^ Formal parameter

specification illegal

43869 Bytes Available

43355 Bytes Free

0 Warning Error(s)

1 Severe Error(s)

Additional query words: QuickBas BasicCom

Keywords: KB39378

-

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

© Microsoft Corporation. All rights reserved.