The Difference Between vbCrLf, vbNewLine and Environment.NewLine

The question, “which is better, vbCrLf, ContrlChars.CrLf, vbNewLine, ControlChars.NewLine, Environment.NewLine, ControlChars.NewLine, or vbNewLine?” is not a question you’d get in C#, since only Environment.NewLine is available.  This is a question that only appears during VB.NET development.

So what’s the difference between the following five statements?

Debug.Print(vbCrLf)
Debug.Print(ControlChars.CrLf)
Debug.Print(vbNewLine)
Debug.Print(ControlChars.NewLine)
Debug.Print(Environment.NewLine)

Usually, nothing.  They all return a carriage return followed by a line feed (“\r\n”).  The last one, Environment.NewLine, is a little special and there is one case where it may return something different.

vbCrLf

vbCrLf is a carry-over from old-school VB days and, for the sake of veteran VB developers, was retained.  It actually is a constant declared in the Microsoft.VisualBasic.Constants class, so it can be referred to as Constants.vbCrLf too.  I wouldn’t be surprised if this constant were eventually dropped in future versions of the VB.NET language.  There’s also another constant with the same value defined as ControlChars.CrLf.  All will return the value “\r\n”, indicating a carriage return (vbCr or “\r”) followed by a line feed (vbLf or “\n”).  In Windows, typically both are expected, even though sometimes you’ll find folks using either one or the other and it is usually rendered correctly.  However, I don’t recommend the practice of using one or the other, or even the string “\r\n”.  Better to just let a predefined constant (like any one of the five mentioned in this article) to do the job.  But like I said earlier, I suspect this constant is on its way out and will likely become deprecated and obsolete.

vbNewLine

vbNewLine (or Constants.vbNewLine) is identical to vbCrLf, just a little easier to understand for newer developers.  It can also be referred to as ControlChars.NewLine.  These constants also return the value “\r\n”.

Downside of ControlChars.CrLf and ControlChars.NewLine

So it’s established that vbCrLf and vbNewLine are identical to ControlChars.CrLf and ControlChars.NewLine, respectively.  So although we’ve got four constants that all really mean the same thing (which is typically ill-advised, since any redundant code or constants are more costly to change later), the main drawback is that they are all VB.NET specific.  Unless you import the Microsoft.VisualBasic reference to your C#, C++, or F# project, none of these constants are available in your code when working with non-VB.NET projects.  These are all constants written solely for the convenience of the Visual Basic.NET developer.

Environment.NewLine

Environment.NewLine in my opinion is the most versatile and the one I recommend.  Not only is it the only one of these five options also available in C#, making it the most universal, but it has the added benefit of being platform-independent.  Well, at least it’s intended to work in either Windows or Unix environments.  In the case of Unix, there is no need for a carriage return, just a new line (“\n”) character will suffice.  So for compatibility between both platforms, this property (emphasizing here that it’s a property and not a constant) will adjust and return either “\r\n” in Windows or simply “\n” in Unix.

The one downside is that it can’t be used to define a constant; it’s a read-only property, not a constant itself like the other options.

Const x As String = "Testing as a constant" & Environment.NewLine ' Doesn't compile

The above will throw the error “Constant expression is required” at design / compile time.  In this particular case, I’d recommend using ControlChars.NewLine instead.

ControlChars Class in C#

Here’s the source for the ControlChars class written in C#, for the case where you don’t want to or can’t use Environment.NewLine:

  public sealed class ControlChars
  {
    public const string CrLf = "\r\n";
    public const string NewLine = "\r\n";
    public const char Cr = '\r';
    public const char Lf = '\n';
    public const char Back = '\b';
    public const char FormFeed = '\f';
    public const char Tab = '\t';
    public const char VerticalTab = '\v';
    public const char NullChar = '\0';
    public const char Quote = '"';
  }

So to sum it up, all five options return the exact same value, except for Environment.NewLine, which can adapt to the platform on which your application is running.  If you don’t believe your application will ever run on another platform but Windows (but why limit yourself?) and you anticipate no possibility of ever using C#, then I would recommend at least being consistent and ensure your entire solution uses only one of these constants.

N95 masks inside a makeshift oven

Making a low-cost dry heat “oven” for N95 masks

In a time when N95 masks are extremely scarce and are difficult to obtain and while healthcare providers have no choice but to reuse masks, makers are stepping up and are trying to fill the gap.

For about $120 USD worth of parts such as a styrofoam shipping box, lightbulbs, and a thermostat with a sensor, I’ve built a heater for N95 masks. This device uses the “dry heat” technique, providing high and consistent heat, out of easily obtainable, off-the-shelf parts.

Disclaimer and Background

I am not a doctor. I am not a scientist. I am not providing official guidance and I do not represent any organization or government in any capacity. I am a software engineer and I write code for a living, which affords me almost no medical knowledge whatsoever. I offer no guarantee of any effectiveness.

Any information presented here may be based on incorrect or unproven assumptions. This site may include information that is already outdated or determined to be just flat-out wrong, especially as more time advances. This was written during the middle of a coronavirus pandemic and the luxury of hindsight to identify the proper paths we should have taken has not yet been afforded to us.

This was inspired by the Make: Plan C initiative, in an attempt to provide not government (“Plan A”), not industry (“Plan B”), but civic (“Plan C”) action to help answer the call, written in the spirit of trying to help by disseminating knowledge in a fast-paced and changing landscape.

This is not my invention, only an interpretation from others ideas I’ve seen online. I was most inspired by Hackerfarm’s article, “HOWTO: LOW COST HEAT STERILIZER FOR VIRUS INACTIVATION.” (Thank you.)

According to practically everyone, including myself, it is believed N95 masks must not be reused and any method to “sanitize” them can lead to degradation and mask failure. Doing so could lead to a false sense of security, their use could be dangerous and could unfortunately lead to death.

Care must be taken when handling used masks and techniques to minimize virus transmission must be used, such as using gloves and bags.

Operation of this device may cause electrocution or start a fire and thus must only be operated by an adult under constant supervision with a fire extinguisher readily handy.

The “dry heat” technique used here will not effectively kill all viruses, bacteria, molds, or fungi. As such, this will not completely sanitize masks.

In addition to the dry heat technique, there are many other methods that researchers are actively testing and validating, including ultraviolet light and vaporized hydrogen peroxide. These may be more effective (yet likely more expensive) than using dry heat.

Please use perform your own research, use your own judgment and make informed decisions from multiple, official sources.

Please use at your own risk.

A makeshift oven for N95 masks

Parts List

N95 masks inside a makeshift oven, focusing on two halogen light bulbs
Two bulbs were sufficient to rapidly and reliably reach the desired 70°C
Close-up of the temperature probe, mounted inside the box
Close-up of the temperature probe, mounted inside the box
Two lightbulbs are mounted through the styrofoam cover
Two lightbulbs are mounted through the styrofoam cover

Operation

Based on the findings of this study, masks were heated to at least 70° Celsius (158° Fahrenheit) for a minimum of 60 minutes.

References and Further Reading

These links were used to research this article. I do not have any affiliation with any of these sites or organizations and cannot attest to their their accuracy or motives. Please also perform your own research outside this list, as this is nowhere near definitive or authoritative.

Stay safe out there. We’ll get through this.

If you made one yourself, please drop me a line and let me know!