Microsoft KB Archive/42666

= QB.EXE &quot;Type Mismatch&quot;, BC.EXE &quot;String Expression Required&quot; =

Article ID: 42666

Article Last Modified on 11/21/2006



This article was previously published under Q42666



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

The following program line causes the QB.EXE environment of QuickBasic to highlight &quot;LEN = 20&quot; and issue the error message &quot;Type Mismatch.&quot; Under the QBX.EXE environment of Microsoft Basic PDS 7.00, &quot;FILE.DAT&quot; is highlighted when the &quot;Type Mismatch&quot; error occurs: OPEN FILE.DAT FOR RANDOM AS #1 LEN = 20 &quot;Type Mismatch&quot; 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 &quot;String Expression Required&quot; and points to the &quot;T&quot; 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 &quot;String Expression Required&quot; message in both the environment and the separate compilation method.

The following is the necessary correction to follow proper syntax: OPEN &quot;FILE.DAT&quot; FOR RANDOM AS #1 LEN = 20

Additional query words: QuickBas BasicCom

Keywords: KB42666

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.