function myGetTerbilang(sValue: string; const useRupiah: Boolean = true): string;
const
Angka : array [1..20] of string =
('', 'Satu', 'Dua', 'Tiga', 'Empat',
'Lima', 'Enam', 'Tujuh', 'Delapan',
'Sembilan', 'Sepuluh', 'Sebelas',
'Dua Belas', 'Tiga Belas', 'Empat Belas',
'Lima Belas', 'Enam Belas', 'Tujuh Belas',
'Delapan Belas', 'Sembilan Belas');
sPattern: string = '000000000000000';var
S : string;
Satu, Dua, Tiga, Belas, Gabung: string;
Sen, Sen1, Sen2: string;
Hitung : integer;
One, Two, Three: integer;
Kata : string;
begin
One := 1;
Two := 2;
Three := 3;
Hitung := 1;
Kata := '';
S := copy(sPattern, 1, length(sPattern) - length(trim(sValue))) + sValue;
Sen1 := Copy(S, 14, 1);
Sen2 := Copy(S, 15, 1);
Sen := Sen1 + Sen2;
while Hitung < 5 do
begin
Satu := Copy(S, One, 1);
Dua := Copy(S, Two, 1);
Tiga := Copy(S, Three, 1);
Gabung := Satu + Dua + Tiga;
if StrToInt(Satu) = 1 then
Kata := Kata + 'Seratus '
else
if StrToInt(Satu) > 1 Then
Kata := Kata + Angka[StrToInt(satu)+1] + ' Ratus ';
if StrToInt(Dua) = 1 then
begin
Belas := Dua + Tiga;
Kata := Kata + Angka[StrToInt(Belas)+1];
end
else
if StrToInt(Dua) > 1 Then
Kata := Kata + Angka[StrToInt(Dua)+1] + ' Puluh ' +
Angka[StrToInt(Tiga)+1]
else
if (StrToInt(Dua) = 0) and (StrToInt(Tiga) > 0) Then
begin
if ((Hitung = 3) and (Gabung = '001')) or
((Hitung = 3) and (Gabung = ' 1')) then
Kata := Kata + 'Seribu '
else
Kata := Kata + Angka[StrToInt(Tiga)+1];
end;
if (hitung = 1) and (StrToInt(Gabung) > 0) then
Kata := Kata + ' Milyar '
else
if (Hitung = 2) and (StrToInt(Gabung) > 0) then
Kata := Kata + ' Juta '
else
if (Hitung = 3) and (StrToInt(Gabung) > 0) then
begin
if (Gabung = '001') or (Gabung = ' 1') then
Kata := Kata + ''
else
Kata := Kata + ' Ribu ';
end;
Hitung := Hitung + 1;
One := One + 3;
Two := Two + 3;
Three := Three + 3;
end;
(* hapus penggunaan rupiah *)
if useRupiah then begin
if length(Kata) > 1 then Kata := Kata + ' Rupiah ';
if (StrToInt(Sen) > 0) and (StrToInt(Sen) < 20) then
begin
if StrToInt(Sen) < 10 then Sen := Copy(Sen, 2, 1);
Kata := Kata + Angka[StrToInt(Sen)+1] + ' Sen';
end
else
if StrToInt(Sen) > 19 then
Kata := Kata + Angka[StrToInt(Sen1)+1] + 'Puluh ' +
Angka[StrToInt(Sen2)+1] + ' Sen';
end;
Result := Kata;
end;
untuk mendapatkan angka terbilang.
sValue: string; -> isi dengan angka berupa string dgn 2 koma di belakang. format : 0.00
const useRupiah: Boolean = true -> menggunakan rupiah atau tidak, default ya.