Microsoft KB Archive/42669

= LINE INPUT#n Drops Null Characters from File; Use INPUT$ =

Article ID: 42669

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic Compiler for Macintosh 1.0
 * Microsoft BASIC Interpreter 1.0
 * Microsoft BASIC Interpreter 1.01 for Macintosh
 * Microsoft BASIC Interpreter 2.0
 * Microsoft BASIC Interpreter 2.1 for Macintosh
 * Microsoft BASIC Interpreter 3.0 for Macintosh
 * Microsoft QuickBasic 1.0
 * Microsoft QuickBasic 1.01
 * Microsoft QuickBasic 1.02
 * Microsoft QuickBasic 2.0
 * Microsoft QuickBasic 2.01
 * Microsoft QuickBasic 3.0
 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft GW-BASIC Interpreter 3.20
 * Microsoft GW-BASIC Interpreter 3.22
 * Microsoft GW-BASIC Interpreter 3.23
 * Microsoft Visual Basic 1.0 Standard Edition

-



This article was previously published under Q42669



SUMMARY
The LINE INPUT #n statement strips null characters (CHR$(0)) from input files. If you want to input null bytes, you must use the INPUT$ function instead of the LINE INPUT #n statement.



Code Sample
The following code segment will print &quot;helloworld&quot; instead of &quot;hello world&quot;: OPEN &quot;test.dat&quot; FOR INPUT AS #1 LINE INPUT #1, a$ PRINT a$ CLOSE #1 where the TEST.DAT data file was created as follows: OPEN &quot;test.dat&quot; FOR OUTPUT AS #1 PRINT #1, &quot;hello&quot; + CHR$(0) + &quot;world&quot; CLOSE #1

Additional query words: QuickBas BasicCom MQuickB 1.00 2.00 2.10 3.00 3.20 4.00 4.00b 4.50 6.00 6.00b 7.00 7.10

Keywords: KB42669

-

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

© Microsoft Corporation. All rights reserved.