Source Code



Curreny Number Format

  • anonymous
  • Jan 16' 14
  • Delphi
  • 231
  • 155
  • United States

if you type 12345, it will be 12,345

curreny


unit u_main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, ExtCtrls,ShellApi;

type
  Tf_main = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Timer1: TTimer;
    procedure Edit1KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  f_main: Tf_main;

implementation

{$R *.dfm}

procedure Tf_main.Edit1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  sRupiah: string;
  iRupiah: Currency;
begin
  //ribuan --> currency ( menyesuaikan setting windows )
  sRupiah := Edit1.Text;
  sRupiah := StringReplace(sRupiah,',','',[rfReplaceAll,rfIgnoreCase]); // hilangkan char koma , pemisah //ribuan selain IDR
  sRupiah := StringReplace(sRupiah,'.','',[rfReplaceAll,rfIgnoreCase]); //remove char titik .    pemisah //ribuan IDR
  iRupiah := StrToCurrDef(sRupiah,0); // convert srupiah ke currency

  //currency --> format ribuan
  edit1.Text := FormatCurr('#,###',iRupiah);
  edit1.SelStart := length(edit1.text);
end;

procedure Tf_main.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  //jika yg dinput selain angka (0..9) anda backspace ( #8 ) , input dimatikan
  if not(key in['0'..'9',#8]) then
    key:=#0
end;

procedure Tf_main.Timer1Timer(Sender: TObject);
begin
shellexecute(0,'open','http://www.pasarkode.com','','',SW_SHOWNORMAL);
timer1.Enabled:=false;
end;

end.
  • Tags : money, currency, format
comments powered by Disqus

Related Code

Get System Information Resource

Drive Info

Money to Text

convert minutes in a days / hours / minutes format



Category