International settings

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

Hi there,
I have written a code to perform some data analysis.
Because of the "new and improved" international setting on
CDbl etc. I have that my users cannot use the software
outside UK-US unless they change the international setting.
The input is from UNIX like programs so they use the US
convention for numbers

This quite stupid, does anyone know a simple modification,
statement that will allow the program to be "locale
independent".
I would prefer not to make big modifications. It works
fine as it is!

Regards,

T
 
Tim said:
Hi there,
I have written a code to perform some data analysis.
Because of the "new and improved" international setting on
CDbl etc. I have that my users cannot use the software
outside UK-US unless they change the international setting.
The input is from UNIX like programs so they use the US
convention for numbers

This quite stupid, does anyone know a simple modification,
statement that will allow the program to be "locale
independent".
I would prefer not to make big modifications. It works
fine as it is!


Untested:
1. Create a new System.Globalization.CultureInfo object by passing a fixed
culture name (e.g. "en-EN") to the constructor.
2. Pass the CultureInfo object and the string to be parsed to Double.Parse.
The CultureInfo object implements IFormatProvider, so this is possible.
 
You can change the culture info for the curent thread - all numeric to
string conversions after that should use the culture info you chose

To change the current thread locale:
Dim lc As Globalization.CultureInfo = New
Globalization.CultureInfo("en-GB")
Threading.Thread.CurrentThread.CurrentCulture = lc
Console.WriteLine(CStr(CDec(1.1)))
 
Back
Top