CALL BYVAL "Parameter Type Mismatch" After DECLARE AS ANY (45892)






This article was previously published under Q45892

SYMPTOMS

Using the CALL subprogramname (BYVAL variable) method of calling an external (non-Basic) routine, where the parameter is specified AS ANY in the DECLARE statement, correctly causes a "Parameter Type Mismatch" at compile time.

To avoid this error, you must add BYVAL and specify the exact type (instead of using AS ANY) in the DECLARE statement, and you must not use BYVAL in the CALL statement. This information applies to Microsoft QuickBasic Versions 4.00, 4.00b, and 4.50, to Microsoft Basic Compiler Versions 6.00 and 6.00b, and to Microsoft Basic Professional Development System (PDS) Version 7.00.

The "Parameter Type Mismatch" error fails to be flagged in the QuickBasic Version 4.50 environment when the external routine is in a Quick Library. QuickBasic Versions 4.00 and 4.00b correctly flag the error.

STATUS

Microsoft has confirmed this to be a bug in QuickBasic Version 4.50. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

The following is taken from the DECLARE statement documentation in the Basic language reference manuals for QuickBasic Versions 4.00, 4.00b, and 4.50 and Basic compiler Versions 6.00 and 6.00b:

You cannot use ANY [in the DECLARE statement] with arguments passed by value.

Code Example

The following code sample should correctly cause a "Parameter Type Mismatch" error on the CALL statement at compile time (where test is an external SUB):
   DECLARE SUB test (variable AS ANY)
   i%=10
   CALL test(BYVAL i%)
				
The following is the correct method to pass by value to the external procedure:
   DECLARE SUB test (BYVAL variable AS INTEGER)
   i%=10
   CALL test(i%)
				

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