KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

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

Article: Q25993
Product(s): See article
Version(s): 4.00 4.00b 4.50
Operating System(s): MS-DOS
Keyword(s): ENDUSER | B_BasicCom B_GWBasicI | mspl13_basic
Last Modified: 26-MAR-1990

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 %").

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.