473,320 Members | 2,164 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 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 1321
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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: 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.