Microsoft KB Archive/37897

= INPUT Statement Removes Unquoted Leading and Trailing Spaces =

Article ID: 37897

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 1.0
 * Microsoft QuickBasic 1.01
 * Microsoft QuickBasic 1.02
 * Microsoft QuickBASIC 1.0b
 * 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 BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1
 * Microsoft GW-BASIC Interpreter 3.20
 * Microsoft GW-BASIC Interpreter 3.22
 * Microsoft GW-BASIC Interpreter 3.23
 * Microsoft QuickBasic Compiler for Macintosh 1.0
 * Microsoft QuickBasic Compiler for Macintosh 1.0
 * Microsoft QuickBasic Compiler for Macintosh 1.0
 * Microsoft BASIC Compiler 6.0b
 * 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

-



This article was previously published under Q37897



SUMMARY
In all versions of Microsoft Basic, the INPUT statement will remove leading and trailing spaces without quotation marks from an input string. The following two processes will help you work around this behavior:


 * Put double quotation marks around the input string.
 * Use LINE INPUT into a string variable.



Code Example
' Run this program and input the following with leading and ' trailing spaces:      test INPUT X$ PRINT X$,LEN(X$) ' You must surround leading and trailing spaces in your input with ' double quotation marks to make them significant: &quot;   test    &quot; ' or else use LINE INPUT: LINE INPUT X$

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

Keywords: KB37897

-

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

© Microsoft Corporation. All rights reserved.