Microsoft KB Archive/198609

= FIX: Write Statement Prints Double-Quote(") =

Article ID: 198609

Article Last Modified on 3/7/2005

-

APPLIES TO


 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Enterprise Edition

-



This article was previously published under Q198609



SYMPTOMS
The Write statement prints out a double-quote within a string field where this should not be allowed.



CAUSE
The Write statement is intended to work with the Input statement. A string field is started and terminated with double quotes, thus placing a double quote within the field indicates the end of the field.



RESOLUTION
If you need to print out a nested double quote, you need to use the Print statement.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been fixed in Visual Basic 5.0.



Steps to Reproduce Behavior
 Create a new project. Form1 is created by default.  Insert the following code into the Form's code window. Private Sub Form_Load Open "test.txt" For Output As #1 Write #1, "Bob " & Chr(34) & "The Man" & Chr(34) & " Bulldog" Close #1 End Sub

 Run the project, then open the file, Test.txt, in Notepad. It contains the following:

"Bob "The Man" Bulldog"

If you try the preceding code sample in Visual Basic 5.0 or later, it results in the following:

"Bob ""The Man"" Bulldog"

To achieve the results of Visual Basic 4.0 in Visual Basic 5.0 or later, use the following:

Print #1, "Bob " & Chr(34) & "The Man" & Chr(34) & " Bulldog"

Keywords: kbbug kbfix kbvbp500fix kbfileio KB198609

-

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

© Microsoft Corporation. All rights reserved.