473,320 Members | 1,856 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,320 software developers and data experts.

how to convert a multiline textbox to a single line string?

I have a multi line text box, i'd like to store the contents of this
textbox to a text file. However when I write the value of '
textbox.text ' to the file it is written verbatim spanning many lines
if enter has been pressed.

I'd like to store the value of the textbox on one single line in the
file. How do i do this?

I assume i'll need to read new line characters from the textbox.text
string, and replace them with some token ?

Is this how I'd do it, and if so can you suggest some sample code?

Thanks,

Gary.

Jan 4 '07 #1
2 9787

ga********@myway.com wrote:
I assume i'll need to read new line characters from the textbox.text
string, and replace them with some token ?
The easiest way I can see of doing that for this particular exercise,
is applying the .Replace() method to the string value of the textbox.

e.g.
string textBoxValue = textBox1.Text.Replace(Environment.NewLine,
"TOKEN");

Where TOKEN is the token you're using to represent it in the single
line, and Environment.NewLine is a constant representing whatever a
newline is in the current environment, as different platforms have
different ways of representing this.

Jan 4 '07 #2
Such an elegent solution. This is exactly what I needed.

Thankyou Bobbo.

Gary.

Bobbo wrote:
ga********@myway.com wrote:
I assume i'll need to read new line characters from the textbox.text
string, and replace them with some token ?

The easiest way I can see of doing that for this particular exercise,
is applying the .Replace() method to the string value of the textbox.

e.g.
string textBoxValue = textBox1.Text.Replace(Environment.NewLine,
"TOKEN");

Where TOKEN is the token you're using to represent it in the single
line, and Environment.NewLine is a constant representing whatever a
newline is in the current environment, as different platforms have
different ways of representing this.
Jan 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Michael C | last post by:
Hi all, I'm trying to add lines to a multiline textbox. Here's what I'd like to end up with in the textbox (as an example): Line1 Line2 Line3 I've tried a couple of methods but nothing...
4
by: Jason | last post by:
I have a string that looks like this? ihelloworld_zzz_yyy In a single vb.net line, I want to remove the frist character and anything after and including the first "_" resulting in : ...
1
by: dhavalmajmundar | last post by:
Hi, I am passing the value of the Multiline Text Box from VB to Crystal. Everything was ok until the User Pressed the Enter Key to separate the line in the Multiline Textbox, Pressing Enter causes...
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: Nethra | last post by:
Hi... I am trying a program which convert the multiline comment type in a program to single line comment type ie. /*have a nice day */ to //have a //nice day
2
by: Nathan Sokalski | last post by:
I have a multiline TextBox that I want to display the text used to create a control in an apsx file. I want each of these to be on a separate line in the TextBox. The only way I know of to place...
1
by: kru | last post by:
Hi All, Simple issue I cannot figure out. I have a multiline textbox, I need to convert the string contents of this textbox into a single line string which I currently write to a textfile. ...
1
by: fniles | last post by:
I am using VB.NET 2008. I have a multiline textbox on the form that I would like to print when the user click on the "Print" button. With my codes below, when the text are in more than 1 page (say...
10
by: JohannKotzeVet | last post by:
Good day! I have a form in Access that has a multiple line textbox (I called it cAbnormalities). This text box is populated by the user ONLY through selection of options from combo boxes. I want...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.