Kylix
Tips

NEW TIPS
Database (135)
Files (612)
Forms (606)
Graphic (536)
IDE (456)
Indy (433)
Internet / LAN (590)
IntraWeb (443)
Kylix (447)
Math (561)
Misc (591)
Multimedia (496)
Objects/
ActiveX (503)

OpenTools API (438)
Printing (459)
Strings (583)
System (721)
VCL (586)

Search Tip
Top15
Add new Tip

Forum

...format a currency according to the specified locale's settings ?
Author: Superhausi
Homepage: http://www.superhausi.ch
[ Print tip ]    

Tip Rating (1):  
     



{
  Um eine Zahl (im Beispiel 1850.5) zu einem korrekten Währungsformat ($ 1, 850.50;
  vom System definiert) zu machen, sollten Sie folgende Funktion verwenden:

  The GetCurrencyFormat function formats a currency value for display.
  By default, the function formats the currency according to the specified locale's settings.
  To make a number (1850.5) to the correct Currency Format ($ 1850.50), use this function:
}

function GetCurrency(number: PChar): string;
var
  
tmpStr: string;
begin
  
SetLength(tmpStr, 255);
  GetCurrencyFormat(LOCALE_SYSTEM_DEFAULT, 0, number, nil, PChar(tmpStr), Length(tmpStr));
  Result := tmpStr;
end;


// Beispiel: Example:

procedure TForm1.Button1Click(Sender: TObject);
begin
  
Application.MessageBox(PChar(GetCurrency(PChar(Edit1.Text))), '', MB_OK);
end;


Rate this tip:

poor
very good


Copyright © Torry's Delphi Pages Torry's Delphi Pages Maintained by Simon Grossenbacher Notes? Comments? Feel free to send... Copyright © 1996-2001