Microsoft KB Archive/35245

= Fixed-Length Strings Are Initialized to NULL (0), Not Blanks =

Article ID: 35245

Article Last Modified on 11/21/2006



This article was previously published under Q35245



SUMMARY
The information below about fixed-length string arrays should be inserted in the following manuals:


 * 1) &quot;Microsoft QuickBasic 4.0: Basic Language Reference&quot;
 * 2) &quot;Microsoft Basic Compiler 6.0: Basic Language Reference&quot; for Versions 6.00 and 6.00b for MS OS/2 and MS-DOS

On Pages 156, 174, and 352, under the DIM, ERASE, and REDIM statements, the above manuals state that elements of string arrays are initialized to null strings (strings of zero length). However, this is not the case with fixed-length strings. Fixed-length strings are initialized as a string of null bytes (with ASCII value of 0). The LEN function always returns the complete length of the fixed-length string. If a fixed-length string is initialized to &quot;&quot; (the null string), it is completely filled with blank spaces (ASCII value of 32).



MORE INFORMATION
This documentation error was corrected in the QuickBasic 4.50 and Microsoft Basic PDS 7.00 documentation.

The following is a code example: DIM j AS STRING * 4 c$ = CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) CLS PRINT &quot;j is printed between the stars: *&quot;; j; &quot;*&quot; PRINT &quot;j looks like a string of blanks, but it's not.&quot; IF j = c$ THEN PRINT &quot;j equals CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0).&quot; IF j <> &quot;&quot; THEN PRINT &quot;j does not equal &quot;; CHR$(34); CHR$(34); IF j <> &quot;   &quot; THEN PRINT &quot; or &quot;; CHR$(34); &quot;    &quot;; CHR$(34); &quot;.&quot; PRINT &quot;But if I set j to &quot;; CHR$(34); CHR$(34); j = &quot;&quot; IF j = &quot;   &quot; THEN PRINT &quot; then j will equal &quot;; CHR$(34); &quot;   &quot;; CHR$(34); &quot;.&quot; END IF The following is the output from the program above: j is printed between the stars: *    * j looks like a string of blanks, but it's not. j equals CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0). j does not equal &quot;&quot; or &quot;   &quot;. But if I set j to &quot;&quot; then j will equal &quot;   &quot;.

Additional query words: QuickBas BasicCom

Keywords: KB35245

-

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

© Microsoft Corporation. All rights reserved.