473,399 Members | 3,302 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,399 software developers and data experts.

Removing commas from Numbers

Hi i have a Text File.
the contents of which are as follows:

name amount(per KiloGram) quantity(in KiloGrams) total($)
rice 2$ 100 200
sugar 10$ 1,000 10,000
salt 5$ 500 2,500

if i want to retrieve the quantity, when i display the value as 1000 in my form it is considering as string and showing me "1,000" because it has comma "," in between, also you can see in the amount in Total field.
i am getting the same problem with total field also.

i am using vb.net and i chose vb as programming language.

can any one help to send me a code snippet to remove comma from a number
(whatever may be the number, even in millions)

Thanks
CrapyCoder
Jan 5 '09 #1
4 24762
nukefusion
221 Expert 100+
You can use the Replace method of the String object to remove the commas, i.e:

Expand|Select|Wrap|Line Numbers
  1. Dim myString As String = "1,000"
  2. myString.Replace(",", string.Empty)
  3.  
Jan 5 '09 #2
store comma separated value in a string.........
Split it based on comma (,).........
now join all parts of spited string in another string.........
Convert this string in integer..................
& you got the results.............
Jan 7 '09 #3
Xennex
7
You could try using the parse method of the "single" or "double" type..

double.Parse("1,000,000")

would give you

1000000.0

append the "ToString" method and you would get

"1000000"
Jan 21 '09 #4
Frinavale
9,735 Expert Mod 8TB
I'd use the Double.Parse() method since it is a double that you want to work with in the first place.

Another suggestion would be to use a MaskedTextBox to format the input in a way that is predictable to you. They are pretty cool :) Check them out.

-Frinny
Jan 21 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Mike | last post by:
I'm trying to come up with a regular expression that matches numbers with commas... but doesn't match numbers formatted without commas. The problem is that I'm trying to parse a file where the...
3
by: Robert Scheer | last post by:
Hi. I have a regularexpression validator control on a page. This regular expression validates a textbox to accept only numbers and commas: validationexpression="*" I am trying to modify this...
1
by: vivekgrs | last post by:
hi i had written text file using vb 6.0 successfully. but i got some problem that i had used the statement for write : Write #2, individual(0); Tab; dd; Tab; dd; Tab; individual(3) ...
14
by: Adrienne Boswell | last post by:
Although this is a client side issue, I am also posting to asp.general in case there is someway to do this only server side (which I would prefer). Here's my form: <form method="post"...
9
by: Shrutisinha | last post by:
I need a help in perl as very new to perl I have balance 1,00.00 and want to change it to 1000.00 I want to remove "," from my balance I am doing parsing my orignal record has a "," in my balance...
2
by: freemld10 | last post by:
Hi guys, Can someone please help me to Format Numbers with commas. The script below have very large number without commas. To read numbers in trillions and billions are hard, without commas to...
1
by: vdesio | last post by:
I am new to ASP. I am using the free ezscheduler asp program to create a calendar for my website. The idea is for employees to schedule their work shifts online. I have modified some of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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
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.