"Parameter Type Mismatch" with Variable Name Same as Parameter (77244)



The information in this article applies to:

  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5

This article was previously published under Q77244

SYMPTOMS

The BC.EXE compiler incorrectly reports "Parameter type mismatch," and possibly "Duplicate definition," when a module contains a variable in the module level that has the same name as a parameter of a SUB or FUNCTION statement in the same module and the following conditions are met:

  • The type of the variable in the module level and the parameter in the SUB or FUNCTION are different.
  • The variable is defined with "DIM <variable> as <type>".
  • The parameter does not have an "AS <type>" clause.
To work around this problem, write the SUB or FUNCTION parameter with an "AS <type>" clause.

STATUS

Microsoft has confirmed this to be a bug in BC.EXE in QuickBasic versions 4.0, 4.0b, and 4.5. This problem was corrected in Microsoft Basic Professional Development System (PDS) version 7.1 (fixlist7.10).

MORE INFORMATION

If the SUB parameter is declared with a type specifier, as in
   SUB sub1 (a!)
				
then BC.EXE incorrectly reports "Duplicate definition" in addition to "Parameter type mismatch."

The following code example demonstrates the problem:
   DECLARE SUB sub1 (a)
   DIM a AS STRING
   y = 123
   CALL sub1(y)
   END
   SUB sub1 (a)         ' Incorrectly causes "Parameter type mismatch"
                        ' Workaround: change to SUB sub1 (a AS SINGLE)
      PRINT "a ="; a
   END SUB
				

Modification Type:MinorLast Reviewed:1/8/2003
Keywords:KB77244