Groups | Blog | Home
all groups > vb.net > october 2007 >

vb.net : escape character not working in string



tshad
10/20/2007 10:48:25 PM
I have the following code

Dim val As Int16 = 7
Dim name As String = "Mr. John"
Dim num As Double = 45.06F
Dim str As String = String.Format("Days Left : {0}. Current DataTime: {1:u}.
\n String: {2}, Float: {3}", val, DateTime.Now, name, num)
Console.WriteLine(str)

The line should break before the "String:", but it doesn't and displays
showing the "\n".

Why doesn't it break at the \n?

Thanks,

Tom


Stephany Young
10/21/2007 12:00:00 AM
Because VB.Net does NOT have any such escape sequences.

Replace the \n with {4} and add Environment.Newline to you parameter list
instead.


[quoted text, click to view]
Herfried K. Wagner [MVP]
10/21/2007 12:00:00 AM
"tshad" <t@home.com> schrieb:
[quoted text, click to view]

'"... {1:u} " & ControlChars.NewLine & " String: {2}..."'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Göran_Andersson
10/21/2007 2:17:26 PM
[quoted text, click to view]

Note:

The ControlChars.NewLine is the newline string used in dos/windows
systems, the same as ControlChars.CrLf. The Environment.NewLine propery
returns the appropriate newline string regarless of system.

--
Göran Andersson
_____
AddThis Social Bookmark Button