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

How do I remove trainling spaces for a compare?

I have two strings that I would like to compare. To guarantee the compare is
not affected by trailing spaces, I would like to remove them.

Will this do: MyTextBox.text.ToString().Trim()?
Nov 15 '05 #1
2 2823
Hi BobM,

Yes, this method removes both trealing and leading whitespaces. If you want
to consider only trailing spaces for removing use TrimEnd method. If you
want to remove only leading spaces use TrimStart. Bear in mind that this
methods return a new string. The original one is not affected. Strings are
immutable.

--
HTH
B\rgds
100

"BobM" <nf*@nospam.com> wrote in message
news:eg**************@TK2MSFTNGP11.phx.gbl...
I have two strings that I would like to compare. To guarantee the compare is not affected by trailing spaces, I would like to remove them.

Will this do: MyTextBox.text.ToString().Trim()?

Nov 15 '05 #2
It depends. Your code returns the trimmed contents of MyTextBox.Text, but it
doesn't actually trim the contents of the textbox. To do that, you would
need to use
MyTextBox.Text = MyTextBox.Text.Trim()

I don't think you need the 'ToString()' bit.

Hope that helps!
"BobM" <nf*@nospam.com> wrote in message
news:eg**************@TK2MSFTNGP11.phx.gbl...
I have two strings that I would like to compare. To guarantee the compare is not affected by trailing spaces, I would like to remove them.

Will this do: MyTextBox.text.ToString().Trim()?

Nov 15 '05 #3

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

Similar topics

2
by: john | last post by:
I am using this to remove everything except the 0-9 and a-z characters, but I also want to remove blanks spaces as well(yes even ones in between words) $strippedtext =...
12
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are...
1
by: Danny | last post by:
Given this: "*" the pattern to remove the htnl code between brackets, how can I remove a series of spaces and just make one space. like here is a series of blank...
1
by: Arjen | last post by:
Hello, In code view I use a tab as mark-up character. When I run my web application I can see the tabs with the source viewer in my browser. Is there a way to remove the tabs, extra spaces...
36
by: Roman Mashak | last post by:
Hello, All! I implemented simple program to eliminate entry from the file having the following structure (actually it's config file of 'named' DNS package for those who care and know): ...
7
by: Mike Johnson | last post by:
How do I remove a item that's been selected from a listview? I'm using Visual Basic 2005 express edition. Thanks
15
by: DanielJohnson | last post by:
I am writing a program in which I am removing all the spaces from the string. I thought that I could do it two ways. One was parsing the string character by character and copying onto another...
1
by: buggtb | last post by:
Hi Guys, I've been given the joyous task of updating some very old scripts at work and I could do with a little help. Our Unix system dumps text files to pseudo spoolers that our windows...
2
by: =?Utf-8?B?UFM=?= | last post by:
Hi, Is there a way to compare PDF, Word Document, Excel using C# like WinDiff utility that compares text file and display the result with the modified text in both the document? -- Thanks,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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
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...

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.