Microsoft KB Archive/42666

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 16:56, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


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

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 "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
                


Additional query words: QuickBas BasicCom

Keywords: KB42666