Format specifiers for VB.NET in Visual Studio in 2013

1k views Asked by At

I've been trying to find a way to render \r\n as actual newlines in the immediate and command window in my VB.NET 4.5.1 application. I came across this question which teaches about the nq specifier, but it appears to apply only to C#. In VB.NET, nq doesn't even appear to work because I get Expression expected printed back out at me.

Is there a different way to make newlines actually show as separate lines in the immediate or command window in VB.NET?

2

There are 2 answers

0
oscilatingcretin On

I've discovered that the solution is to use System.Diagnostics.Debug.Print(). To reproduce the original issue, entering this into the Immediate window...

? "a" & vbCrLf & "a"

...just returns this:

"a a"

However, using this...

System.Diagnostics.Debug.Print("a" & vbCrLf & "a")

...actually shows the newline:

a
a
0
user2728841 On

An easier way in visual studio 2015 is to do this in the debug window:

?string,nq

You can also do the debug version in earlier versions of VS

?System.Diagnostics.Debug.Print(string,nq)