Home All Groups Group Topic Archive Search About

How Do I Put An End Of Line Character In A TextBox

Author
16 May 2006 5:14 PM
Christopher Lusardi
How would I put an end of line character in the second line below?

   Textbox1.Text = "Hello "
   Textbox1.Text =
   Textbox1.Text = "World"

Thanks,
Chris Lusardi

Author
16 May 2006 5:30 PM
Ahmed
textbox1.text "Hello " & vbcrlf & vbcrlf & "World"
Author
16 May 2006 6:34 PM
cj
I didn't know vbcrlf existed.  At the top of some of my programs I have
dim crlf as string = Chr(13) & Chr(10)
guess I don't need that but now I have to type vbcrlf instead of crlf.

Ahmed wrote:
Show quoteHide quote
> textbox1.text "Hello " & vbcrlf & vbcrlf & "World"
>
Author
16 May 2006 6:41 PM
Charlie Brown
I use Ahmed's example in my code as well.
Author
16 May 2006 10:08 PM
Herfried K. Wagner [MVP]
"cj" <cj@nospam.nospam> schrieb:
>I didn't know vbcrlf existed.  At the top of some of my programs I have
> dim crlf as string = Chr(13) & Chr(10)
> guess I don't need that but now I have to type vbcrlf instead of crlf.

No, you don't need it.  Note that VB.NET has a 'ControlChars.NewLine'
constant too, and 'Environment.NewLine' will return the system's new line
character.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
17 May 2006 8:42 AM
Cor Ligthert [MVP]
Herfried,

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.

Cor

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht
news:OBLK0UTeGHA.4040@TK2MSFTNGP05.phx.gbl...
> "cj" <cj@nospam.nospam> schrieb:
>>I didn't know vbcrlf existed.  At the top of some of my programs I have
>> dim crlf as string = Chr(13) & Chr(10)
>> guess I don't need that but now I have to type vbcrlf instead of crlf.
>
> No, you don't need it.  Note that VB.NET has a 'ControlChars.NewLine'
> constant too, and 'Environment.NewLine' will return the system's new line
> character.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
17 May 2006 8:46 AM
Cor Ligthert [MVP]
You saw it probably already, I forgot the :-)

Cor

Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schreef in bericht
news:umfpW2YeGHA.3572@TK2MSFTNGP03.phx.gbl...
> Herfried,
>
> 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.
>
> Cor
>
> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht
> news:OBLK0UTeGHA.4040@TK2MSFTNGP05.phx.gbl...
>> "cj" <cj@nospam.nospam> schrieb:
>>>I didn't know vbcrlf existed.  At the top of some of my programs I have
>>> dim crlf as string = Chr(13) & Chr(10)
>>> guess I don't need that but now I have to type vbcrlf instead of crlf.
>>
>> No, you don't need it.  Note that VB.NET has a 'ControlChars.NewLine'
>> constant too, and 'Environment.NewLine' will return the system's new line
>> character.
>>
>> --
>> M S   Herfried K. Wagner
>> M V P  <URL:http://dotnet.mvps.org/>
>> V B   <URL:http://classicvb.org/petition/>
>
>
Author
17 May 2006 12:30 PM
cj
Is controlchars.newline available in both VB and C#?  If so perhaps
Herfried is promoting using something that would be the same from
language to language.  VB also has vbNewLine.  Frankly everything is
getting long.  I almost stuck with dimming my own, crlf, as it is 4
chars instead of vbCrLf's 6.  And actually thought about using nl for
newline but it wasn't quite as obvious when reading the code.  Anyway I
went with vbCrLf as it doesn't need a dim and I'll get used to it.


Cor Ligthert [MVP] wrote:
Show quoteHide quote
> You saw it probably already, I forgot the :-)
>
> Cor
>
> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schreef in bericht
> news:umfpW2YeGHA.3572@TK2MSFTNGP03.phx.gbl...
>> Herfried,
>>
>> 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.
>>
>> Cor
>>
>> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht
>> news:OBLK0UTeGHA.4040@TK2MSFTNGP05.phx.gbl...
>>> "cj" <cj@nospam.nospam> schrieb:
>>>> I didn't know vbcrlf existed.  At the top of some of my programs I have
>>>> dim crlf as string = Chr(13) & Chr(10)
>>>> guess I don't need that but now I have to type vbcrlf instead of crlf.
>>> No, you don't need it.  Note that VB.NET has a 'ControlChars.NewLine'
>>> constant too, and 'Environment.NewLine' will return the system's new line
>>> character.
>>>
>>> --
>>> M S   Herfried K. Wagner
>>> M V P  <URL:http://dotnet.mvps.org/>
>>> V B   <URL:http://classicvb.org/petition/>
>>
>
>
Author
17 May 2006 2:20 PM
Herfried K. Wagner [MVP]
"cj" <cj@nospam.nospam> schrieb:
> Is controlchars.newline available in both VB and C#?

No, 'ControlChars.NewLine' is part of "Microsoft.VisualBasic.dll".

> language to language.  VB also has vbNewLine.  Frankly everything is
> getting long.  I almost stuck with dimming my own, crlf, as it is 4 chars
> instead of vbCrLf's 6.

Well, you could import the 'ControlChars' type and then use 'NewLine' and
'CrLf' throughout your code, without any bad performance implications.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
17 May 2006 2:22 PM
Herfried K. Wagner [MVP]
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb:
> 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'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
17 May 2006 3:16 PM
Cor Ligthert [MVP]
LOL

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht
news:ub3uc1beGHA.2076@TK2MSFTNGP04.phx.gbl...
> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb:
>> 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'.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>