BUG: Visual Basic .NET or Visual Basic 2005 code examples overwrite text in console window (306720)
The information in this article applies to:
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic 2005 Express Edition
- Microsoft .NET Framework
This article was previously published under Q306720 SYMPTOMS Many of the Visual Basic code samples in the .NET Framework
documentation use the ControlChars.Cr constant to write output to the console. However, this constant,
which is intended to separate lines of output in the console, causes the lines
of output to be written over each other on a single line in the
console. For example, if a sample intends to write the following
output to the console: if you use the following code:
Console.Write( "First Line" & ControlChars.Cr)
Console.Write( "Second Line")
the following output results: CAUSE This problem occurs because many of the Visual Basic
samples use the ControlChars.Cr constant, which represents ASCII character 13 (a carriage
return), to separate intended lines of output. This character instructs console
output to return to the beginning of the current line rather than move to the
beginning of the next line. RESOLUTION To work around this problem, replace the use of ControlChars.Cr with either the ControlChars.CrLf or ControlChars.NewLine constant. Both of these constants represent a combination of the
carriage return (ASCII 13) and line feed (ASCII 10) characters and cause output
to move to the beginning of the next line on the console. After you
apply this workaround to the preceding code sample, the new code appears as
follows:
Console.Write( "First Line" & ControlChars.NewLine)
Console.Write( "Second Line")
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.
Modification Type: | Major | Last Reviewed: | 1/20/2006 |
---|
Keywords: | kbvs2005applies kbvs2005swept kbvs2002sp1sweep kbbug kbpending kbreadme KB306720 |
---|
|