NewLine - For All Platforms
A lot of us code vbCrLf at the end of a string when we want to move to a new line in the output.
MsgBox( _
"This is a message" _
 & NewLine & _
"on two lines.")
The "CrLf" stands for "carriage return, line feed" and is compiled into hex 0D & 0A. It's been the way I've programmed it for ages. For Windows platforms, that's not a problem. But if there's a chance that your code will run on another platform, you probably want to use Environment.vbNewLine. There are .NET ports for non-Windows environments, such as Mono.
The reason is that for some of these other environments, CrLf isn't a "new line". The Microsoft doc states that:
"The property value of NewLine is a constant customized specifically for the current platform and implementation of the .NET Framework."
Note that Microsoft also provides a different NewLine in the namespace Microsoft.VisualBasic.ControlChars. This code ...
Imports _
Microsoft.VisualBasic.ControlChars
Public Class Form1
Private Sub Button1_Click( ...
MsgBox( _
"This is a message" _
& NewLine & _
"on two lines.")
End Sub
End Class
... will give you a CrLf and not a platform independant value. (But then, the Imports for Microsoft.VisualBasic.ControlChars would probably fail on another platform anyway.)


Comments
Dan,
While I don’t do cross platform, and I am still using VB6, I can appreciate this issue.
I created an Instrument Control thingy and added a button to allow the user to include a vbcrlf in a user created prompt string…
There was just one tiny problem with this.
Saving it was no problem… But…
I was using Line Input to read in a line at a time! (of the Procedure File) Opps…
Remedy? I added support for \n…
May your grins be big, very big, and long…
Mike Sr.
Dan,
I started using vbNewLine a while back (on VB6) because when developing a “StringBuilder” class I was told that for some inexplainable reason vbNewLine resolved slightly more quickly than vbCrLf. I never tested it myself, but took them at their word.
More to the point though, vbNewLine is more human readable – if you go for that sort of thing
Denzil
I’m not sure about faster, but vbNewLine doesn’t get converted to a platform independant form. Only “Environment.NewLine” (when using the .NET Framework) does.