How to print in newline?

sanox

New member
Joined
Aug 4, 2009
Messages
1
Programming Experience
Beginner
Hi, i am new to vb.

Here is my problem.

VB.NET:
If Me.BackColor = Color.Red Then
            MessageBox.Show("Hello " & name & "You have chosen the Red Scheme", "Greeting")


        End If

I would like to have a newline at the "You have chosen the Red Scheme"
i tried to put \n after the 'name', but it did not work. Thanks.
 
I've always used

vbCrLf
Which only works if you have a reference to Microsoft.VisualBasic, which none of my projects do so that'll never work without re-adding it.

On a side note, Environment.NewLine isn't OS specific, so on the rare chance s/he starts programming on the Mono framework (Linux/Mac) vbCrLf (and vbCr, vbLf, vbNewLine) will always fail whereas Environment.NewLine will always work, no matter what.

This goes for System.IO.Path.DirectorySeparatorChar and System.IO.Path.Combine() too, they'll always work.
 
It should be noted that ControlChars.Newline is a string with the value set to vbCrLf whereas Environment.NewLine is a ReadOnly string property set to the value of new line in the current environment.

VB.NET:
Public Shared Const NewLine As String = vbCrLf
 
JuggaloBrotha said:
Which only works if you have a reference to Microsoft.VisualBasic, which none of my projects do so that'll never work without re-adding it.
You are always referencing Microsoft.VisualBasic, VB projects won't compile without the Runtime library. You might have disabled the project level namespace import for this, though.

I prefer the vbNewLine constant btw.
 
Back
Top