Subject | Re: [IBO] How to programaticly protect regional options of number, currency format.... |
---|---|
Author | Florian Hector |
Post date | 2006-03-07T12:06:45Z |
> How to programaticly protect regional options of number, currencyNot really recommended to prevent a user from doing something perfectly normal with his/her very own
> (format)...
> My friend use my program.Yesterday he installed some other program and
> then regional nuber (format) settings was changed.
> After that my program chrashed every time when use StrToFloat().I
> change regional settings manualy...but how to protect this in code?
> Why StrToFloat() doesn't work in booth cases:
>
> 1) 1.222,22
> 2) 1,222.22
computer. You as developer are obliged to take care of things like that. What will you do if your
application has to run on different machines with different regional settings? Give then different
versions of your program? Do it the way the other program did and change the regional setting to
your programs like?
Back to the problem.
You have to use the overloaded function of StrToFloat:
...
var
fs: TFormatSettings;
begin
GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, fs);
StrToFloat('123,1233', fs);
...
Florian