work with formated numbers

Chinavo

Member
Joined
Jul 16, 2008
Messages
16
Programming Experience
1-3
Hi

i have a listview where i want to show some numbers separated by '

So the format will be like this:

1'000'000.00

So first i put the numbers to the listview by using a textbox. Later
i need to take the numbers out and work on with them. But i can not calculate
or do whatever with them in that format. so i'd like to know how to handle that the best way.

Thanx for ur help

chinavo
 
Use the same CultureInfo/NumberFormatInfo you used to format the number to that string format to Parse it back to numeric data. Here's an example using a custom NumberFormatInfo (because that formatting differs from my default culture number formatting):
VB.NET:
Dim nfi As New Globalization.NumberFormatInfo
nfi.NumberDecimalSeparator = "."
nfi.NumberGroupSeparator = "'"
Dim d As Decimal = 1000
Dim s As String = d.ToString("n2", nfi)
d = Decimal.Parse(s, nfi)
You can see how using the the current culture info will allow you to format numbers like user would like to see them wherever in the world, and parsing it back again.
 
Back
Top