Function Terbilang IDR dan USD

Function ini dipakai untuk menerjemahkan angka menjadi susunan kata atau kalimat :

Misal :

Rp.   1.100.000 ( Satu Juta Seratus Ribu Rupiah )

USD. 5,500.56  ( Lima Ribu Lima Ratus Poin Lima Puluh Enam US Dollar )

FUNCTION USD
*—————————–*
Function Terbilangusd (nBil,sCurr,cSen)
*—————————–*
Local sBil,sBil1,sBil2,sBil3,sBil4,sBil5
Local sMil,sJut,sRib,sSat,sSen
sApit := “##”
If nBil > 999999999999.9994
&&12345678901234567      9,999,999,999
Return “Out Of Bound …………………”
Endif
sBil    := Str(nBil,17,4)
sBil1   := Substr(sBil, 1,3)  // Milyar
sBil2   := Substr(sBil, 4,3)  // Juta
sBil3   := Substr(sBil, 7,3)  // Ribu
sBil4   := Substr(sBil,10,3)  // Satuan
sBil5   := Substr(sBil,13,5)  // Sen
sMil    := Iif(Val(sBil1)=0,””,ratusanusd(sBil1)+”Billion ” )
sJut    := Iif(Val(sBil2)=0,””,ratusanusd(sBil2)+”Million “)
sRib    := Iif(Val(sBil3)=0,””,Iif(Val(sBil3)=1,” One Thousand “,ratusanusd(sBil3)+” Thousand “))
sSat    := Iif(Val(sBil4)=0,sCurr,ratusanusd(sBil4)+sCurr)
sSen    := Iif(Val(sBil5)>0,ratusandolar(sBil5)+csen,”Zero”+ratusandolar(sBil5)+cSen)
//sSen    := Iif(Val(sBil5)>0,ratusanusd(sBil5)+cSen,”Zero”+ratusanusd(sBil5)+cSen)
// SSen    := Iif(Val(sBil5)<=0,” Zero “+ratusanusd(sBil5)+cSen,” “+ratusanusd(sBil5)+cSen)
Return sApit+” “+sMil+sJut+sRib+sSat+sSen+” “+sApit

*————————*
Function ratusanusd (sString)
*————————*
Local sBil1,sBil2
Local nBil1,nBil2,nBil21,nBil22
bBlg    := {|n|Rtrim(Substr(“One     Two     Three   “+;
“Four    Five    Six     “+;
“Seven   Eight   Nine    “,8*n-7,8))}
nBil1   := Val(Left(sString,1))
nBil2   := Val(Right(sString,2))
nBil21  := Val(Substr(sString,2,1))
nBil22  := Val(Right(sString,1))
sBil1   := Iif(nBil1=0,””,Iif(nBil1=1,” One Hundred “,Eval(bBlg,nBil1)+” Hundred “))
sBil2   := IIf(nBil2=0 ,””,;
Iif(nBil2<10,Eval(bBlg,nBil22)+” “,;
Iif(nBil2=10,”Ten “,;
Iif(nBil2=11,”Eleven   “,;
Iif(nBil2=12,”Twelve   “,;
Iif(nBil2=13,”Thirteen “,;
Iif(nBil2=14,”Fourteen “,;
Iif(nBil2=15,”Fifteen  “,;
Iif(nBil2=16,”Sixteen  “,;
Iif(nBil2=17,”Seventeen”,;
Iif(nBil2=18,”Eighteen “,;
Iif(nBil2=19,”Nineteen “,;
Iif(nBil2=20,”Twenty “,;
Iif(nBil2>20 .and. nbil2 <30,”Twenty “+Eval(bBlg,nBil22)+””,;
Iif(nBil2=30,”Thirty “,;
Iif(nBil2>30 .and. nbil2 <40,”Thirty “+Eval(bBlg,nBil22)+””,;
Iif(nBil2=40,”Fourty”,;
Iif(nBil2>40 .and. nbil2 <50,”Fourty “+Eval(bBlg,nBil22)+””,;
Iif(nBil2=50,”Fifty  “,;
Iif(nBil2>50 .and. nbil2 <60,”Fifty “+Eval(bBlg,nBil22)+””,;
Iif(nBil2=60,”Sixty  “,;
Iif(nBil2>60 .and. nbil2 <70,”Sixty “+Eval(bBlg,nBil22)+””,;
Iif(nBil2=70,”Seventy”,;
Iif(nBil2>70 .and. nbil2 <80,”Seventy “+Eval(bBlg,nBil22)+””,;
Iif(nBil2=80,”Eighty “,;
Iif(nBil2>80 .and. nbil2 <90,”Eighty “+Eval(bBlg,nBil22)+””,;
Iif(nBil2=90,”Ninety “,;
Iif(nBil2>90 .and. nbil2 <100,”Ninety “+Eval(bBlg,nBil22)+””,;
Eval(bBlg,nBil21)+” “+;
Iif(nBil22=0,””,Eval(bBlg,nBil22)+” “)) )))))))))))))))))))))))))))
Return sBil1+sBil2                               &&12 345678901234567890123456789

Function SayJumlahusd (nNum,sSen,sCurr,nNum1,nNum2)
*———————————————-*
Local sOut
If nNum > 999999999999.9994
&&  12345678901234567
Return
Endif
//sOut  :=  Just(CutStr(terbilangusd(nNum,sCurr,sSen),nNum1,nNum2),nNum1)
sOut  :=  Just(CutStr(terbilangusd(nNum,sSen,sCurr),nNum1,nNum2),nNum1)
If Right(sOut,1) == “#”
// sOut := CutStr(terbilangusd(nNum,sCurr,sSen),nNum1,nNum2)+” “
sOut := CutStr(terbilangusd(nNum,sSen,sCurr),nNum1,nNum2)+” “
Endif
Return Padr(sOut,nNum1)

*————————*
Function ratusandolar (sString)
*————————*
Local sBil1,sBil2,sBil3,sBil4
Local nBil1,nBil2,nBil3,nBil4
bBlg    := {|n|Rtrim(Substr(“One     Two     Three   “+;
“Four    Five    Six     “+;
“Seven   Eight   Nine    “,8*n-7,8))}
nBil1   := Val(Substr(sString,2,1))
nBil2   := Val(Substr(sString,3,1))
nBil3   := Val(Substr(sString,4,1))
nBil4   := Val(Substr(sString,5,1))
sBil1   := Iif(nBil1>0,Eval(bBlg,nBil1)+” “,”Zero “)
sBil2   := IIf(nBil2>0,Eval(bBlg,nBil2)+” “,”Zero “)
sBil3   := IIf(nBil3>0,Eval(bBlg,nBil3)+” “,”Zero “)
sBil4   := IIf(nBil4>0,Eval(bBlg,nBil4)+” “,”Zero “)

Return sBil1+sBil2+sBil3+sBil4

FUNCTION IDR

*—————————–*
Function Terbilang (nBil,sCurr,cSen)
*—————————–*
Local sBil,sBil1,sBil2,sBil3,sBil4,sBil5
Local sMil,sJut,sRib,sSat,sSen
sApit := “#”
If nBil > 999999999999.94
Return “Out Of Bound …………………”
Endif
sBil    := Str(nBil,15,2)
sBil1   := Substr(sBil, 1,3)  // Milyar
sBil2   := Substr(sBil, 4,3)  // Juta
sBil3   := Substr(sBil, 7,3)  // Ribu
sBil4   := Substr(sBil,10,3)  // Satuan
sBil5   := Substr(sBil,13,3)  // Sen
sMil    := Iif(Val(sBil1)=0,””,Ratusan(sBil1)+”Milyard ” )
sJut    := Iif(Val(sBil2)=0,””,Ratusan(sBil2)+”Juta “)
sRib    := Iif(Val(sBil3)=0,””,Iif(Val(sBil3)=1,”Seribu “,Ratusan(sBil3)+”Ribu “))
sSat    := Iif(Val(sBil4)=0,sCurr,Ratusan(sBil4)+sCurr)
sSen    := Iif(Val(sBil5)=0,”Nol”+Ratusan(sBil5)+cSen,” “+Ratusan(sBil5)+cSen)
Return sApit+” “+sMil+sJut+sRib+sSat+sSen+” “+sApit

*————————*
Function Ratusan (sString)
*————————*
Local sBil1,sBil2
Local nBil1,nBil2,nBil21,nBil22
bBlg    := {|n|Rtrim(Substr(“Satu    Dua     Tiga    “+;
“Empat   Lima    Enam    “+;
“Tujuh   Delapan Sembilan”,8*n-7,8))}
nBil1   := Val(Left(sString,1))
nBil2   := Val(Right(sString,2))
nBil21  := Val(Substr(sString,2,1))
nBil22  := Val(Right(sString,1))
sBil1   := Iif(nBil1=0,””,Iif(nBil1=1,”Seratus “,Eval(bBlg,nBil1)+” Ratus “))
sBil2   := IIf(nBil2=0 ,””,;
Iif(nBil2<10,Eval(bBlg,nBil22)+” “,;
Iif(nBil2=10,”Sepuluh “,;
Iif(nBil2=11,”Sebelas “,;
Iif(nBil2<20,Eval(bBlg,nBil22)+” Belas “,;
Eval(bBlg,nBil21)+” Puluh “+;
Iif(nBil22=0,””,Eval(bBlg,nBil22)+” “)) ))))
Return sBil1+sBil2

*———————-*
Function Just(sStrJust,nLen)
*———————-*
Local nInsert
If sStrJust = Space(nLen-1) .OR. Len(sStrJust) >= nLen .OR. Alltrim(sStrJust)=””
Return sStrJust
Endif
nInsert   := nLen-Len(StrTran(sStrJust,” “,””))
sStrJust  := Alltrim(sStrJust)
Do While Len(sStrJust) != nLen
sStrJust  := StrTran(sStrJust,” “,” “+chr(254),1,nInsert)
If Len(sStrJust) = nLen
Exit
ElseIf Len(sStrJust) > nLen
Do While Len(sStrJust) > nLen
sStrJust     := StrTran(sStrJust,chr(254)+chr(254),” “,1,1)
sStrJust     := StrTran(sStrJust,chr(254),””,1,1)
Enddo
Endif
Enddo
Return StrTran(sStrJust,chr(254),” “)

*———————————*
Function CutStr (sStrIn,Num1,Num2)
*———————————*
Local i,n,StrOut
If (Num1*Num2) > Len(sStrIn)
sStrIn := sStrIn + Space(Num1*Num2-Len(sStrIn))
Endif

For i:= 1 to Num2
n       := Rat(” “,Left(sStrIn,Num1))
sStrOut := Left(sStrIn,n-1)
sStrIn  := Substr(sStrIn,n+1)
Next
Return sStrOut

*———————————————-*
Function SayJumlah (nNum,sSen,sCurr,nNum1,nNum2)
*———————————————-*
Local sOut
If nNum > 999999999999.99
Return
Endif
//sOut  :=  Just(CutStr(terbilang(nNum,sCurr,sSen),nNum1,nNum2),nNum1)
sOut  :=  Just(CutStr(terbilang(nNum,sSen,sCurr),nNum1,nNum2),nNum1)
If Right(sOut,1) == “#”
sOut := CutStr(terbilang(nNum,sSen,sCurr),nNum1,nNum2)+” “
//  sOut := CutStr(terbilang(nNum,sCurr,sSen),nNum1,nNum2)+” “
Endif
Return Padr(sOut,nNum1)

7 Tanggapan

  1. halo mau tanya..kok pas saya coba eror yah..knp yah…oh yah bisa dibuat berupa addin saja tidak thxxxx

    • Makasih sebelumnya berkenan kasih coretan di blog saya,

      Mohon maaf saya kurang paham maksud anda mengenai error , error dimana yaaa
      error waktu coba minigui exstended atau ……. ?

      Maaf dan makasih

  2. Usd. Tus d blkangnya pke 00 ga

  3. Klo usd itu blakang pke 00 g sih

Berikan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Logout / Ubah )

Twitter picture

You are commenting using your Twitter account. Logout / Ubah )

Facebook photo

You are commenting using your Facebook account. Logout / Ubah )

Google+ photo

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

Ikuti

Get every new post delivered to your Inbox.

%d blogger menyukai ini: