|
-
Jun 11th, 2007, 01:46 AM
#1
Thread Starter
Addicted Member
[2005] Going to a new line in a label (in html its \n)
How do I go to a new line (in label or text box)
say
Code:
Public label2 As New Label()
label2.Text = "Hello\nMy name is joe."
which would do
Hello
My name is joe.
thats what I want, anyone know how?
Thanks
Last edited by Icyculyr Fr0st; Jun 11th, 2007 at 02:02 AM.
-
Jun 11th, 2007, 01:50 AM
#2
Fanatic Member
Re: [2005] Going to a new line in a label (in html its \n)
vb Code:
messageBox.Show("Hello" & vbNewLine & "My name is Joe")
-
Jun 11th, 2007, 02:00 AM
#3
Re: [2005] Going to a new line in a label (in html its \n)
Don't use vbNewLine in VB.NET. Use ControlChars.NewLine or Environment.NewLine.
By the way, this:
Code:
label2.Text = "Hello\nMy name is joe."
would work in C-based langauges like C# but VB doesn't support those escape sequences.
-
Jun 11th, 2007, 02:30 AM
#4
Thread Starter
Addicted Member
Re: [2005] Going to a new line in a label (in html its \n)
-
Jun 11th, 2007, 02:47 AM
#5
Re: [2005] Going to a new line in a label (in html its \n)
ControlChars.NewLine is exactly the same as vbNewLine or \n and none of those are platform independent. That said, .NET's not realistically platform independent either so it really doesn't matter what you use.
-
Jun 11th, 2007, 06:05 AM
#6
Hyperactive Member
Re: [2005] Going to a new line in a label (in html its \n)
 Originally Posted by Icyculyr Fr0st
Going to a new line in a label (in html its \n)
A new line in HTML is <BR>
-
Jun 11th, 2007, 07:48 PM
#7
Re: [2005] Going to a new line in a label (in html its \n)
 Originally Posted by penagate
ControlChars.NewLine is exactly the same as vbNewLine or \n and none of those are platform independent. That said, .NET's not realistically platform independent either so it really doesn't matter what you use.
ControlChars.NewLine is not the same as "\n".
C-based languages support inline escape sequences that VB does not. In C-based languages "\r" is a carriage return and "\n" is a line feed. The standard Windows new line is a carriage return followed by a line feed. On most common non-Windows systems the standard line break is just a line feed.
In VB the vbNewLine is a constant defined as a carriage return followed by a new line. ControlChars.NewLine is a constant member of the ControlChars class defined as vbNewLine. As such, both vbNewLine and ControlChars.NewLine are equivalent to "\r\n" in C-based languages. VB also supports vbCr, vbLf, ControlChars.Cr and ControlChars.Lf for the individual carriage return and line feed characters.
Environment.NewLine is not a constant so it cannot be used where a constant value is required, unlike ControlChars.NewLine et al. Environment.NewLine will return a carriage return followed by a line feed on Windows and just a line feed on non-Windows systems.
If you use "\n" for a new line in C# then you are actually using a non-standard value on Windows. This is not an issue in most cases but there may be some where it would matter. If you want platform independent code in VB or C# you should use Environment.NewLine for all your line breaks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|