Cor Ligthert said:
I once asked you to make a testset and you told than that you had not the
time to type that.
Why are you advicing that long code, while there is that simple vbcrlf.
In C# I find the 'ControlChars.NewLine' a very good alternative for the
literal. But VB has a better solution for that.
Well, first, we have to distinguish between methods/properties to determine
the system's new line character and on getting a system-independent new line
character sequence. The first can be done using 'Environment.NewLine' in
both VB.NET and C#. For the latter there are different ways in VB.NET and
C#. In C# typically new line character sequences are embedded as escape
codes inside string literals:
\\\
string s = "Hello\r\nWorld"
///
The equivalent code in VB.NET would be
\\\
Dim s As String = "Hello" & ControlChars.CrLf & "World"
///
or alternatively
\\\
Dim s As String = "Hello" & vbCrLf & "World"
///
'vbNewLine' and 'ControlChars.NewLine' both are constants which have the
same value as 'vbCrLf'. IIRC 'vbNewLine' has been introduced in VBA once to
support /different/ newline character sequences in VBA on Windows and on the
Mac.
Personally I generally prefer 'ControlChars.NewLine' or 'vbNewLine' over
'ControlChars.CrLf' and 'vbCrLf' because its name is semantically more
meaningful and I do not care about the value of the constant too much.
However, if the exact character codes are important, then I prefer 'CrLf'
and 'vbCrLf'.