Kamis, 24 Maret 2011

scripe pascal

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Button2: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
close;
end;

procedure TForm1.Button2Click(Sender: TObject);
var angka:string;
begin
angka:= edit1.text;
if (length(angka)>3) and (length(angka)<7) then
insert('.',angka,length(angka)-2) else
 if (length(angka)>6) and (length(angka)<10) then
 begin
insert('.',angka,length(angka)-2);
insert('.',angka,length(angka)-6);
end else
 if (length(angka)>9) and (length(angka)<13) then
 begin
insert('.',angka,length(angka)-2);
insert('.',angka,length(angka)-6);
insert('.',angka,length(angka)-10);
end;
edit2.text:=angka;

end;

procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;

end.
unit Unit1;

interface

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

{
=
}
type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Memo1: TMemo;
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

//Konversi Nilai Mata Uang ke dalam bahasa Indonesia
Function Terbilang(Uang:Int64):String;
Begin
      If (Uang = 1) Then Terbilang:='Satu '
      Else If (Uang = 2) Then Terbilang:='Dua '
      Else If (Uang = 3) Then Terbilang:='Tiga '
      Else If (Uang = 4) Then Terbilang:='Empat '
      Else If (Uang = 5) Then Terbilang:='Lima '
      Else If (Uang = 6) Then Terbilang:='Enam '
      Else If (Uang = 7) Then Terbilang:='Tujuh '
      Else If (Uang = 8) Then Terbilang:='Delapan '
      Else If (Uang = 9) Then Terbilang:='Sembilan '
      Else If (Uang = 0) Then Terbilang := ' '
      Else If (Uang = 10) Then Terbilang := 'Sepuluh '
      Else If (Uang = 11) Then Terbilang := 'Sebelas '
      Else If (Uang >= 12) And (Uang <= 19) Then Terbilang:=Terbilang(Uang Mod 10) + 'Belas '
Else If (Uang >=20) And (Uang <=99) Then Terbilang := Terbilang(Uang div 10) + 'Puluh ' + Terbilang(Uang Mod 10)
Else If (Uang >=100) And (Uang <=199) Then Terbilang := 'Seratus ' + Terbilang(Uang - 100)
Else If (Uang >= 200) And (Uang <=999) Then Terbilang := Terbilang(Uang div 100) + 'Ratus ' + Terbilang(Uang Mod 100)
Else If (Uang >=1000) And (Uang <=1999) Then Terbilang := 'Seribu ' + Terbilang(Uang - 1000)
Else If (Uang >=2000) And (Uang <=999999) Then Terbilang := Terbilang(Uang div 1000) + 'Ribu ' + Terbilang(Uang Mod 1000)
Else If (Uang >=1000000) And (Uang <=999999999) Then Terbilang := Terbilang(Uang div 1000000) + 'Juta ' + Terbilang(Uang Mod 1000000)
Else If (Uang >=1000000000) And (Uang <=999999999999) Then Terbilang :=Terbilang(Uang div 1000000000) + 'Milyar ' + Terbilang(Uang Mod 1000000000)
Else If (Uang >=1000000000000)  Then Terbilang :=Terbilang(Uang div 1000000000000) + 'Triliun ' + Terbilang(Uang Mod 1000000000000);
End;

procedure TForm1.Button1Click(Sender: TObject);
begin
 Memo1.Text := Terbilang(StrToInt64(Edit1.Text));
end;

end.

0 komentar:

Posting Komentar

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites