PC Review


Reply
Thread Tools Rate Thread

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

 
 
garyusenet@myway.com
Guest
Posts: n/a
 
      4th Jan 2007
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.

 
Reply With Quote
 
 
 
 
Bobbo
Guest
Posts: n/a
 
      4th Jan 2007

(E-Mail Removed) 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.

 
Reply With Quote
 
garyusenet@myway.com
Guest
Posts: n/a
 
      4th Jan 2007
Such an elegent solution. This is exactly what I needed.

Thankyou Bobbo.

Gary.

Bobbo wrote:

> (E-Mail Removed) 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove line from multiline textbox Sale Microsoft C# .NET 3 19th Apr 2006 02:14 PM
multiline textbox line feed deja@2bytes.co.uk Microsoft ASP .NET 0 21st Mar 2006 01:03 PM
Re: Line shift in multiline textbox ! WebD Microsoft VB .NET 1 16th Sep 2005 12:38 AM
setting multiline textbox controlsource to string through code Jesper F Microsoft Access Form Coding 1 21st Feb 2005 07:23 PM
deleting a line from a multiline textbox Harry Hudini Microsoft VB .NET 2 3rd Nov 2003 10:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:06 AM.