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

how to get rid of blanks

hi

I want the empty spaces to be removed after a string has been entered by a user
i.e how do i get rid of the trailing blanks in the following string....
'John
So that the value now displays
'John
Any help is appreciated.
Nov 22 '05 #1
3 1323
string s = "John ";
s = s.Trim();

"Jade" <an*******@discussions.microsoft.com> wrote in message
news:82**********************************@microsof t.com...
hi,

I want the empty spaces to be removed after a string has been entered by a user. i.e how do i get rid of the trailing blanks in the following string.....
'John '
So that the value now displays
'John'
?

Any help is appreciated.

Nov 22 '05 #2
Jade wrote:
hi,

I want the empty spaces to be removed after a string has been entered by a user.
i.e how do i get rid of the trailing blanks in the following string.....
'John '
So that the value now displays
'John'
?

Any help is appreciated.


"John ".TrimEnd();
Nov 22 '05 #3
Use the Trim or TrimEnd methods. An example would be:

string name = "John ";
string trimName = name.Trim();

Trim method -
http://msdn.microsoft.com/library/de...strimtopic.asp

TrimEnd method -
http://msdn.microsoft.com/library/de...imendtopic.asp

"Jade" <an*******@discussions.microsoft.com> wrote in message
news:82**********************************@microsof t.com...
hi,

I want the empty spaces to be removed after a string has been entered by a user. i.e how do i get rid of the trailing blanks in the following string.....
'John '
So that the value now displays
'John'
?

Any help is appreciated.

Nov 22 '05 #4

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

Similar topics

1
by: Andreas Lauffer | last post by:
I use Blanks in ColumnNames ( I know that this isnīt very good, but a lot of code and querys had to be changed if I would remove all blanks in all columnnames). When I link this tables with ODBC...
3
by: Jade | last post by:
hi I want the empty spaces to be removed after a string has been entered by a user i.e how do i get rid of the trailing blanks in the following string.... 'John So that the value now displays...
6
by: jalkadir | last post by:
I am trying to find a way to remove the leading and tailing blanks from a string. What I have come up with is not doing the work as I expected; because if the value I pass to the function is "...
2
by: Laurent | last post by:
DB2 8.1 ------- db2 => create table test (COL1 VARCHAR(10)) db2 => insert into test values ('A') db2 => insert into test values ('A ') db2 => insert into test values ('B') db2 => insert into...
2
by: William Kossack | last post by:
I have an Access table with one primary key and am attempting to update a non-key field, using UPDATE tblMethtest SET fev1timemeth = '' WHERE SID = '0041R'; When I do this, the field...
2
by: John Hoge | last post by:
I have a regex "^\d{5}$" that does not allow blanks, but the RegularExpressionValidator does not fire for empty fields. Is there a way to make it do so? I would rather not include a separate...
34
by: Registered User | last post by:
Hi experts, I'm trying to write a program that replaces two or more consecutive blanks in a string by a single blank. Here's what I did: #include <stdio.h> #include <string.h> #define MAX 80
8
by: wyo | last post by:
I'd like to display folder names without line breaks so I tried the following replace folders = f.replace(/ /g, '&nbsp;'); but the script stop without an error. Any idea? Is there a better...
10
by: Diego F. | last post by:
Hi all. I have an application that receives a message from a socket in an array from a certain size. As the array size may be longer that the message received, the end of the array has blank...
4
by: eBob.com | last post by:
I have a RichTextBox in which I'd like blanks to appear different from nothing. Imagine a file which does not fill up the RTB. You can't tell how many, if any, blanks might follow the last...
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
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
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
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.