FIX: Write Statement Prints Double-Quote(")

ID: Q198609


The information in this article applies to:
  • Microsoft Visual Basic Standard, Professional, and Enterprise Editions for Windows, version 4.0


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.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new project. Form1 is created by default.


  2. 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
     


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

Additional query words:

Keywords : kbFileIO kbVBp kbVBp400bug kbVBp500fix kbGrpVB kbGrpVBDB
Version : WINDOWS:4.0
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: January 5, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.