"Type Mismatch" Passing Numeric Constants in CALL Statement (20539)



The information in this article applies to:

  • Microsoft QuickBASIC 1.0
  • Microsoft QuickBASIC 1.0a
  • Microsoft QuickBASIC 1.0b
  • Microsoft BASIC Compiler
  • Microsoft BASIC Interpreter for Apple Macintosh 2.0
  • Microsoft BASIC Interpreter for Apple Macintosh 2.1
  • Microsoft BASIC Interpreter for Apple Macintosh 3.0

This article was previously published under Q20539

SUMMARY

When you pass numeric constants as arguments in a CALL statement to invoke a subprogram, they must agree in type (integer%, single-precision!, or double-precision#) with the formal parameters in the subprogram SUB statement, or else you will get a "Type Mismatch" error.

This information applies to Microsoft QuickBASIC Versions 1.00, 1.00a, 1.00b, BASIC compiler Version 1.00, and BASIC interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

MORE INFORMATION

An example of making CALL arguments and SUB formal parameters agree is as follows:
' It is best to explicitly type numeric constants with %, !, and #
' to be sure that they are passed with the correct type:
CALL Test (2%, 4.5!, 8.5436#)
STOP
' Formal parameters X%, Y!, Z# must agree in type with CALL arguments:
SUB Test(X%, Y!, Z#) STATIC
PRINT X%, Y!, Z#
END SUB
				
Note the arguments passed to DEF FN functions do not have to agree in type with the formal parameters used in the DEF FN statement.

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