KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q42666: QB.EXE "Type Mismatch", BC.EXE "String Expression Required"

Article: Q42666
Product(s): See article
Version(s): 4.00 4.00b 4.50
Operating System(s): MS-DOS
Keyword(s): ENDUSER | SR# S890217-143 B_BasicCom | mspl13_basic
Last Modified: 15-DEC-1989

This article describes a case where a syntax error in the filename for
an OPEN statement gives "Type Mismatch" in the environment and a
different (but more informative) message, "String Expression
Required," in BC.EXE. This is a design limitation.

The following program line causes the QB.EXE environment of QuickBASIC
to highlight "LEN = 20" and issue the error message "Type Mismatch."
Under the QBX.EXE environment of Microsoft BASIC PDS 7.00, "FILE.DAT"
is highlighted when the "Type Mismatch" error occurs:

   OPEN FILE.DAT FOR RANDOM AS #1 LEN = 20

"Type Mismatch" occurs because a string variable was expected instead
of FILE.DAT, which is by default a single-precision variable.

The BC.EXE compiler instead identifies this syntax error as "String
Expression Required" and points to the "T" in FILE.DAT.

This information applies to QB.EXE in QuickBASIC Versions 4.00, 4.00b,
and 4.50, to QB.EXE in Microsoft BASIC Compiler Versions 6.00 and
6.00b, and to QBX.EXE in Microsoft BASIC PDS Version 7.00 for MS-DOS.

QuickBASIC Versions 2.00, 2.10, and 3.00 issue the "String Expression
Required" message in both the environment and the separate compilation
method.

The following is the necessary correction to follow proper syntax:

   OPEN "FILE.DAT" FOR RANDOM AS #1 LEN = 20

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.