Terbilang Dengan Foxpro

Naaa fungsi ini juga penting jika anda membuat faktur ato nota dalam penjualan atau pembelian


FUNCTION terbilang
 PARAMETER NUM          && 1234567890123456
 numcar     = TRAN(NUM,"9999999999999.99")
 POIN    = VAL(SUBS(numcar,15,2))
 ratus    = VAL(SUBS(numcar,11,3))
 ribu     = VAL(SUBS(numcar,8,3))
 juta      = VAL(SUBS(numcar,5,3))
 milyar     = VAL(SUBS(numcar,2,3))
 trilyun = VAL(SUBS(numcar,1,1))
 hasil     = ""
 kata      = ""

IF ratus <> 0
 hasil = KONVERSI(ratus)
 ENDIF

IF ribu <> 0
 IF ribu <> 1
 hasil = KONVERSI(ribu) +" RIBU " +hasil
 ELSE
 hasil = "SERIBU "+ hasil
 ENDIF
 ENDIF

IF juta <> 0
 hasil = KONVERSI(juta) +" JUTA " +hasil
 ENDIF

IF milyar <> 0
 hasil = KONVERSI(milyar)+" MILYAR " +hasil
 ENDIF

IF trilyun <> 0
 hasil = KONVERSI(trilyun)+" TRILYUN " +hasil
 ENDIF

IF POIN <> 0
 hasil = hasil + " RUPIAH "+KONPOIN(POIN)+" SEN"
 ELSE
 hasil = hasil + " RUPIAH"
 ENDIF
 RETURN hasil

PROCEDURE KONVERSI
 PARAMETER X
 DIME H(10)
 H[1] = "SATU"
 H[2] = "DUA"
 H[3] = "TIGA"
 H[4] = "EMPAT"
 H[5] = "LIMA"
 H[6] = "ENAM"
 H[7] = "TUJUH"
 H[8] = "DELAPAN"
 H[9] = "SEMBILAN"
 H[10] = ""
 HURUF= TRAN(X,"999")
 D1 = VAL(SUBS(HURUF,1,1))
 D2 = VAL(SUBS(HURUF,2,1))
 D3 = VAL(SUBS(HURUF,3,1))

IF D1 = 0
 D1 = 10
 ENDIF

IF D2 = 0
 D2 = 10
 ENDIF

IF D3 = 0
 D3 = 10
 ENDIF

kata = ""

*--------- PULUHAN
 IF D2 = 1
 IF D3 = 10
 kata = "SEPULUH"
 ELSE
 IF D3 = 1
 kata = "SEBELAS"
 ELSE
 kata =  H[D3]+"BELAS"
 ENDIF
 ENDIF
 ELSE
 IF D2 = 10
 kata = H[D3]
 ELSE
 kata = H[D2] + " PULUH "+H[D3]
 ENDIF
 ENDIF

*------------- RATUSAN
 IF D1 = 1
 kata = "SERATUS "+kata
 ELSE
 IF D1 <> 10
 kata = H[D1] + " RATUS "+kata
 ENDIF
 ENDIF
 RETURN kata

PROCEDURE KONPOIN
 PARAMETER X
 DIME H(10)
 H[1] = "SATU"
 H[2] = "DUA"
 H[3] = "TIGA"
 H[4] = "EMPAT"
 H[5] = "LIMA"
 H[6] = "ENAM"
 H[7] = "TUJUH"
 H[8] = "DELAPAN"
 H[9] = "SEMBILAN"
 H[10] = ""
 HURUF= TRAN(X,"99")

D1 = VAL(SUBS(HURUF,1,1))
 D2 = VAL(SUBS(HURUF,2,1))

IF D1 = 0
 D1 = 10
 ENDIF

IF D2 = 0
 D2 = 10
 ENDIF

kata = ""

*--------- PULUHAN
 IF D1 = 1
 IF D2 = 10
 kata = "SEPULUH"
 ELSE
 IF D2 = 1
 kata = "SEBELAS"
 ELSE
 kata =  H[D2]+"BELAS"
 ENDIF
 ENDIF
 ELSE
 IF D1 = 10
 kata = H[D2]
 ELSE
 kata = H[D1] + " PULUH "+H[D2]
 ENDIF
 ENDIF
 RETURN kata

cara pakenya gini

Fungsi  : terbilang(nNumeric)

Parameter : nNumeric = Tipe field numeric

?terbilang(20000000)
DUA PULUH JUTA RUPIAH

Tinggalkan Balasan

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

Logo WordPress.com

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

Gambar Twitter

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

Foto Facebook

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

Foto Google+

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

Connecting to %s

%d blogger menyukai ini: