By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,327 Members | 849 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,327 IT Pros & Developers. It's quick & easy.

textbox text property

P: n/a
This question is driving me nuts because I'm sure its easy to do...

If I have a text box control and a user enters some text with new line
characters in it, how could I turn around and parse that in VB?

I've tried using "\n", "\r\n", etc. and nothing seems to work. Now, I've
been trying to detect it using IndexOf, perhaps thats my problem?

Thanks!
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
vbnewline

--
Jay Feldman
Ja********@NOSPAMmonmouth.com
"Bill Rowell" wrote:
This question is driving me nuts because I'm sure its easy to do...

If I have a text box control and a user enters some text with new line
characters in it, how could I turn around and parse that in VB?

I've tried using "\n", "\r\n", etc. and nothing seems to work. Now, I've
been trying to detect it using IndexOf, perhaps thats my problem?

Thanks!

Nov 20 '05 #2

P: n/a
* "Bill Rowell" <bi***@donotspam.com> scripsit:
This question is driving me nuts because I'm sure its easy to do...

If I have a text box control and a user enters some text with new line
characters in it, how could I turn around and parse that in VB?

I've tried using "\n", "\r\n", etc. and nothing seems to work. Now, I've
been trying to detect it using IndexOf, perhaps thats my problem?


Use 'ControlChars.NewLine', 'Environment.NewLine', or 'vbNewLine':

\\\
Me.Label1.Text = _
"Hello" & ControlChars.NewLine & _
"World"
///

Notice that this won't reduce performance, because the compiler detects
that the whole text on the right side of the assignment is a single
constant and stores it as one constant in the binary image. At runtime,
no concatenations are performed.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
<URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 20 '05 #3

P: n/a
I've tried Environment.Newline and ControlChars.NewLine and neither of those
worked.

I'll try vbnewline.

-Bill

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OW**************@TK2MSFTNGP09.phx.gbl...
* "Bill Rowell" <bi***@donotspam.com> scripsit:
This question is driving me nuts because I'm sure its easy to do...

If I have a text box control and a user enters some text with new line
characters in it, how could I turn around and parse that in VB?

I've tried using "\n", "\r\n", etc. and nothing seems to work. Now, I've been trying to detect it using IndexOf, perhaps thats my problem?


Use 'ControlChars.NewLine', 'Environment.NewLine', or 'vbNewLine':

\\\
Me.Label1.Text = _
"Hello" & ControlChars.NewLine & _
"World"
///

Notice that this won't reduce performance, because the compiler detects
that the whole text on the right side of the assignment is a single
constant and stores it as one constant in the binary image. At runtime,
no concatenations are performed.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
<URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 20 '05 #4

P: n/a
Bill,

You can use the Split function instead of the split method on the string
object which accepts a string delimiter and the code is a little simpler:

<code (VB.NET) >
Dim astr() As String = Split(Me.TextBox1.Text, Environment.NewLine)
Dim s As String
For Each s In astr
Console.WriteLine(s + "+(CrLf)")
Nex
</code>
-Sam Matzen
"Bill Rowell" <bi***@donotspam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
This question is driving me nuts because I'm sure its easy to do...

If I have a text box control and a user enters some text with new line
characters in it, how could I turn around and parse that in VB?

I've tried using "\n", "\r\n", etc. and nothing seems to work. Now, I've
been trying to detect it using IndexOf, perhaps thats my problem?

Thanks!

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.