473,396 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

textbox text property

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
4 1463
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
* "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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chumley the Walrus | last post by:
I'm using this sql parameter: MyCommand.Parameters("@Sport").value = Server.HtmlEncode(sport) to get a value from a textbox control: <asp:TextBox Name="sport" id="sport"...
1
by: Martin | last post by:
Dear Group Sorry for bothering you again but I need expert advice on this. I have placed a HTML textbox on my aspx form and converted it to run as a server control. At some point in my code I...
2
by: Alex Shirley | last post by:
HI I'm trying to iterate through all the textboxes on a webpage and trim them for spaces. i.e. If a user enters " hello world " we correct it to "hello world" So far I've come up with...
11
by: Keith | last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing...
2
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
6
by: JohnR | last post by:
I have a table with 1 row which is used to hold some application wide items (one item per field, hence I only need 1 row). I want to bind one of the fields to a textbox. After setting up the...
3
by: Barry | last post by:
A beginners question to someone that isn't a beginner ;) I've forgotton a lot. The code below isn't what I want to do but it demonstrates succinctly my problem. I want to drop a "MyTextBox"...
1
by: rn5a | last post by:
I want to create a custom control that encapsulates a Button & a TextBox. When the Button is clicked, the user is asked a question using JavaScript confirm (which shows 2 buttons - 'OK' &...
7
by: Anil Gupte | last post by:
I have read a lot about getting lines from a multiline textbox in VB.Net. However, I cannot for the life of me figure out how to write to a multiline textbox. Basically, I have created an array of...
1
by: shapper | last post by:
Hello, I am working on Library which will include various controls. One of these controls has a TextBox. I am using a property named Value to define the TextBox text: ' Value Private...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.