code_junkie

In Delphi, how can you have currency data types shown in different currencies in different forms?

Nov 10th, 2011
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. function CurrFormatFromLCID(const AValue: Currency; const LCID: Integer = LOCALE_SYSTEM_DEFAULT): string;
  2. var
  3. AFormatSettings: TFormatSettings;
  4. begin
  5. GetLocaleFormatSettings(LCID, AFormatSettings);
  6. Result := CurrToStrF(AValue, ffCurrency, AFormatSettings.CurrencyDecimals, AFormatSettings);
  7. end;
  8.  
  9. function USCurrFormat(const AValue: Currency): string;
  10. begin
  11. Result := CurrFormatFromLCID(AValue, 1033); //1033 = US_LCID
  12. end;
  13.  
  14. function FrenchCurrFormat(const AValue: Currency): string;
  15. begin
  16. Result := CurrFormatFromLCID(AValue, 1036); //1036 = French_LCID
  17. end;
  18.  
  19. procedure TestIt;
  20. var
  21. val: Currency;
  22. begin
  23. val:=1234.56;
  24. ShowMessage('US: ' + USCurrFormat(val));
  25. ShowMessage('FR: ' + FrenchCurrFormat(val));
  26. ShowMessage('GB: ' + CurrFormatFromLCID(val, 2057)); // 2057 = GB_LCID
  27. ShowMessage('def: ' + CurrFormatFromLCID(val));
  28. end;
Add Comment
Please, Sign In to add comment