International Number Formats

  • Thread starter Thread starter Roger
  • Start date Start date
R

Roger

I am currently working on an application that is being
used mostly in the US but recently has been purchased by
several users outside the US, mostly in South America. The
application uses an Access 2000 database for storing the
data.

The problem I am seeing is that when numbers and currency
values are entered into the application, the regional
settings of the users machine formats the numbers to use
their local settings. For example, if you enter $1,000.00
the number is automatically transformed to $1.000,00 which
is how the Spanish language treats the number. When the
application attempts to store the number in the database,
an error occurs. The error states "Cast from string
$1.000,00 to type 'Single' is not valid".

Since I do not specifically add the punctuation or control
the format in any way in the code, I am not sure how to
approach the problem. If anyone has any ideas, I would be
very grateful for your suggestions. I would like to
resolve the problem in such a way that I do not have to
have different versions for different areas of the world.

Thanks in advance for any assistance you might be able to
provide!
 
You can parse for other cultures' number formats
explicitly by specifying their culture info in a parse
method:

Console.WriteLine(Int32.Parse("1.000,00",
NumberStyles.Any, new CultureInfo("es-AR")));

Where es-AR = español Argentina (see the CultureInfo class
docs for all cultures)

There are more sophisitcated ways to accomodate cultures
in your apps, but I'm not familiar with them (try
searching for Globalization in .NET, should turn up some
resources).

Richard
 
Back
Top