This is funny, I was just coming here to ask the same question, thanks a ton, I cant believe something this simple doesnt pop up in more search engines... heh
but the importance to using ControlChars.NewLine and Environment.NewLine is that if your app is ever to be ran on a system with an OS other than Windows vbNewLine and sending the chr10 + 13 combo will both cause the app to crash
using ControlChars.NewLine and Environment.NewLine means you're making a call to the framework which simply inserts the carrage return character of the OS the app is running on
right now .Net is for Windows only (sorry Mono for Linux just doesnt count yet) so it's not a problem, but it might be later on
CR (carriage return) is ascii 13
LF (line feed) is ascii 10
Environment.NewLine and vbNewLine are strings, length 2, of one CR followed by one LF. vbCRLF is old money for the same thing - a string of CR followed by LF. vbCR and vbLF also existed if you wanted just one - necessary for interaction with UNIX systems where just a line feed is used as line separator.
You would be encouraged to use Environment.NewLine rather than vbNewLine, because Environment.NewLine exists in other .NET syntaxes, but vbNewLine does not. By using vb-only versions of cross-language .NET functions and constants, you are reducing your ability to read/cross-train to another .NET syntax; something that may needlessly restrict your career development and cut you off from a wide variety of example code on the web.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.