I want to remove all commas from a numerical form field.
I know that Replace(",", "") will to the job, but Replace(',', '') seems
more appropriot but does not work.
Any efficient suggestions would be appreciated.
Thank,
Mike 7 6023
Mike <mi********@com.nospam> wrote: I want to remove all commas from a numerical form field.
I know that Replace(",", "") will to the job, but Replace(',', '') seems more appropriot but does not work.
Replace (char, char) replaces one character with another - you want to
replace one character with nothing.
Any efficient suggestions would be appreciated.
Well, the first question is: have you checked that Replace(",", "")
isn't fast enough already?
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Mike,
How does it not work? There are overloads of Replace that take two
characters as the arguments. Are you getting a compile time exception?
Can you show an example where it does not work?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Mike" <mi********@com.nospam> wrote in message
news:eJ**************@TK2MSFTNGP15.phx.gbl... I want to remove all commas from a numerical form field.
I know that Replace(",", "") will to the job, but Replace(',', '') seems more appropriot but does not work.
Any efficient suggestions would be appreciated.
Thank,
Mike
Mike,
When you call the Replace method, are you storing the return value?
Calling Replace does not replace the characters on the string you call it
on, rather, it performs the operation on a new string, and returns that. My
guess is that you are not storing the return value and using that.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Mike" <mi********@com.nospam> wrote in message
news:eJ**************@TK2MSFTNGP15.phx.gbl... I want to remove all commas from a numerical form field.
I know that Replace(",", "") will to the job, but Replace(',', '') seems more appropriot but does not work.
Any efficient suggestions would be appreciated.
Thank,
Mike
On Tue, 7 Dec 2004 15:59:37 -0500, Nicholas Paldino [.NET/C# MVP] wrote: Mike,
When you call the Replace method, are you storing the return value? Calling Replace does not replace the characters on the string you call it on, rather, it performs the operation on a new string, and returns that. My guess is that you are not storing the return value and using that.
Hope this helps.
Actually, no, that's not the reason it is failing. His invocation that is
failing, Replace(',','') has in invalid second parameter. '' is not a
valid char. There is no empty char, so he must use the overload that takes
two strings to replace , with nothing.
--
Tom Porterfield
'' does not compile, no null character. I can use Replace(string, string) I
am simply looking for a very fast efficient way.
Thanks,
Mike
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eS**************@TK2MSFTNGP09.phx.gbl... Mike,
How does it not work? There are overloads of Replace that take two characters as the arguments. Are you getting a compile time exception?
Can you show an example where it does not work?
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Mike" <mi********@com.nospam> wrote in message news:eJ**************@TK2MSFTNGP15.phx.gbl...I want to remove all commas from a numerical form field.
I know that Replace(",", "") will to the job, but Replace(',', '') seems more appropriot but does not work.
Any efficient suggestions would be appreciated.
Thank,
Mike
Tom,
The best way to put it is what is the fastest way to strip a char or char[]
from a string.
Guess I should have said that to begin with.
Thanks,
Mike
"Tom Porterfield" <tp******@mvps.org> wrote in message
news:b1***************@tpportermvps.org... On Tue, 7 Dec 2004 15:59:37 -0500, Nicholas Paldino [.NET/C# MVP] wrote:
Mike,
When you call the Replace method, are you storing the return value? Calling Replace does not replace the characters on the string you call
it on, rather, it performs the operation on a new string, and returns that.
My guess is that you are not storing the return value and using that.
Hope this helps. Actually, no, that's not the reason it is failing. His invocation that is failing, Replace(',','') has in invalid second parameter. '' is not a valid char. There is no empty char, so he must use the overload that
takes two strings to replace , with nothing. -- Tom Porterfield
"Mike" <mi********@com.nospam> wrote in message
news:eJ**************@TK2MSFTNGP15.phx.gbl... I want to remove all commas from a numerical form field.
I know that Replace(",", "") will to the job, but Replace(',', '') seems more appropriot but does not work.
Any efficient suggestions would be appreciated.
The fastest way is to not do it. Why are you removing the commas? If it's
part of parsing the string into a numeric value, try something like:
float theValue = Single.Parse(theString, NumberStyles.Currency)
which will accept commas, $ etc. You have many options for NumberStyles. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their...
|
by: Joe Bloggs |
last post by:
I have a general question on best practice regarding data access. I have
the code below, a static method defined in a class that I use in a data
layer dll. The method takes a string as its...
|
by: jg |
last post by:
If I need to reuse regex pattern or let non dotnet com client to reuse the
pattern to match against different strings, what is the best way?
How should I free up the resources held by regex?
...
|
by: Johannes Unfried |
last post by:
Problem
Best practice needed to marshal STL data from managed code to unmanaged code & vice vers
Details
managed code is written in managed C++ & accesses the unmanaged code (i.e. lives in a...
|
by: David Lozzi |
last post by:
I need to have a string available per page, i.e. the SQL Connection String. What's the best way of doing this? Right now I have it loaded into a session variable, but I think I should do something...
|
by: |
last post by:
I have an app that retrieves data from an Access database. At the moment I
have the SQL string as a Const in my app. I understand this is not best
practice. I don't want the user to have access to...
|
by: Fredrik Melin |
last post by:
I have a "Inventory" Object that contains the product and all its fields.
The problem is that I am getting soooooo many functions under main Inventory
class so it becames impossible to initalize...
|
by: MikeG |
last post by:
When creating a class library is it wrong or not a 'Best Practice' to
reference a property of an object from within a constructor or method of
that object? I recall being told not to do this but I...
|
by: Rich |
last post by:
The procedure below checks if a character entered into a cell of a
datagridview is contained in a string array of valid characters for this
particular cell. It seems kludgy. I am asking what the...
|
by: mythescriptid |
last post by:
Hi All,
I know templates and STL might have been discussed many a times here, I'm bit of newbie as far as templates are concerned and was itching to test my new found linking of templates. I would...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
| | |