473,405 Members | 2,187 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,405 software developers and data experts.

Help with carriage return

How come this code doesn't seem to work?

textBox1.Text=textBox1.Text.Replace("\r\n\r\n","\r \n");

I want to remove all blank lines in a textBox.
Nov 16 '05 #1
6 1262
Actually, after another test it seems like it might be working. Would
someone just verify that the code structure is correct?
Nov 16 '05 #2
Try this

textBox1.Text=textBox1.Text.Replace(@"\r\n\r\n",@" \r\n");
"Keith Smith" wrote:
How come this code doesn't seem to work?

textBox1.Text=textBox1.Text.Replace("\r\n\r\n","\r \n");

I want to remove all blank lines in a textBox.

Nov 16 '05 #3
No, that'd replace string literals, rather than escape sequences, and the
OP's code was fine.

I'd prefer the following though:

textBox1.Text=textBox1.Text.Replace(System.Environ ment.NewLine +
System.Environment.NewLine, System.Environment.NewLine);

Not as succinct, but more portable.

"EastDawnRitual" <Ea************@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
Try this

textBox1.Text=textBox1.Text.Replace(@"\r\n\r\n",@" \r\n");
"Keith Smith" wrote:
How come this code doesn't seem to work?

textBox1.Text=textBox1.Text.Replace("\r\n\r\n","\r \n");

I want to remove all blank lines in a textBox.

Nov 16 '05 #4
> I'd prefer the following though:

textBox1.Text=textBox1.Text.Replace(System.Environ ment.NewLine +
System.Environment.NewLine, System.Environment.NewLine);

Not as succinct, but more portable.


Is there a reason you are using System.Environment.NewLine instead of
Environment.NewLine?
Nov 16 '05 #5
"Keith Smith" <ke*********@verizon.net> wrote in message
news:pQ8Qd.18695$uc.9826@trnddc05...
I'd prefer the following though:

textBox1.Text=textBox1.Text.Replace(System.Environ ment.NewLine +
System.Environment.NewLine, System.Environment.NewLine);

Not as succinct, but more portable.


Is there a reason you are using System.Environment.NewLine instead of
Environment.NewLine?


Just to make it clear to him what namespace it's in...
Nov 16 '05 #6
Sorry, make it clear to you ;D

Serves me right for not checking the OP.

"Sean Hederman" <us***@blogentry.com> wrote in message
news:cu**********@ctb-nnrp2.saix.net...
"Keith Smith" <ke*********@verizon.net> wrote in message
news:pQ8Qd.18695$uc.9826@trnddc05...
I'd prefer the following though:

textBox1.Text=textBox1.Text.Replace(System.Environ ment.NewLine +
System.Environment.NewLine, System.Environment.NewLine);

Not as succinct, but more portable.


Is there a reason you are using System.Environment.NewLine instead of
Environment.NewLine?


Just to make it clear to him what namespace it's in...

Nov 16 '05 #7

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

Similar topics

3
by: Eric B | last post by:
I am looking for a text control (or API) that can emulate the behavior of CodeWrite where you can move the cursor in any direction on a blank text area and begin typing (so you are not confined to...
3
by: Canes_Rock | last post by:
The information posted at: ...
5
by: Pia | last post by:
Please help! I'm trying to get my xsl to produce 0x0D, not just 0x0A. Any ideas on how to do this? Right now, if I try the following, my output only shows 0x0a: <xsl:variable name="cr"...
2
by: Andrew Chanter | last post by:
I have a VBA function that returns a string including "vbcr" (VB Carriage Return) to seperate a list into multiple rows, eg Item1 & vbcr & Item2 & vbcr & Item3 This works as planned in the...
2
by: eagleofjade | last post by:
I am trying to import data from a Word document into an Access table with VBA. The Word document is a form which has various fields. One of the fields is a field for notes. In some cases, this...
3
by: Jon | last post by:
Hi... I'm getting stumped over the something that MUST be simple...basically, I'm trying to replace the characters 0D0A with a crlf, using Regex.Replace(). The problem is, the replaced string...
2
by: Matt Mercer | last post by:
Hi all, I am having a frustration problem, and I have read about 25 newsgroup postings that do not have a satisfying answer :) The problem appears to be common where carriage returns are lost...
3
by: Dinsdale | last post by:
I have an xml file that is read into an object using serialization. One of the objects has a string field called delimeter that I want to contain a carriage return. Instead of trying to include the...
6
by: shajias | last post by:
Hi, I am having a xml code like this <name> I am having a carriage return here. Second line with carriage return. This is the last line. </name>
5
by: Icarus - iD_Ten_T helper | last post by:
First of all, my apologies if this should be in a php newsgroup and not here, but I thought this the best place to start. I want to parse the text from a <textareaform element but when I pass...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.