"Type Mismatch" Using PRINT VAL("100.1 %") or VAL("E%") (25993)






This article was previously published under Q25993

SUMMARY

A "Type Mismatch" error occurs for the PRINT VAL("100.0 %") statement, because the percent (%) symbol can be appended only to integer constants, and 100.0 is a floating-point constant. Basic notices the "%" symbol despite its separation with a space from the floating-point constant 100.0.

"Type Mismatch" also properly occurs for PRINT VAL("E%") and PRINT VAL("D%"), where "E" represents single-precision exponential notation, and "D" represents double-precision exponential notation.

The following statements print 100.0 without error:
   PRINT VAL("100.0 *")
   PRINT VAL("100.0 !")
   PRINT VAL("100.0 #")
				
This behavior occurs in Microsoft QuickBasic Versions 4.00, 4.00b, 4.50 for MS-DOS, and in Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS and OS/2.

Please note that QuickBasic Version 3.00 and Microsoft GW-Basic Versions 3.20, 3.22, and 3.23 fail to give an error for the statement PRINT VAL("100.0 %").

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