Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: David Mustakim
  Where is David Mustakim?
 Jakarta
 Indonesia
 David Mustakim
 To: sandeep singh
  Where is sandeep singh?
 ludhiana
 India
 sandeep singh
 Tags
Subject: RE: Convert
Thread ID: 396006 Message ID: 396007 # Views: 56 # Ratings: 1
Version: Visual FoxPro 9 Category: VFP and .NET
Date: Wednesday, January 22, 2014 9:06:41 AM         
   


> Hi Experts
> How can Convert a Numeric Value like (12345) to (ONE TWO THREE FOUR FIVE KGS)
> Sandeep Singh (Ludhiana)
** Terbilang = "say-it / in-words"
** [Satu ,Dua ,Tiga ,Empat ,Lima ,Enam ,Tujuh ,Delapan ,Sembilan ,Sepuluh ,Sebelas ] = "one, two ... eleven"
** Milyar = billion
** Juta = million
** ribu = thousand
** ratus = hundred
** puluh = ten
** belas = teen
** 

FUNCTION Terbilang(tnNum)
lcPokok = [Satu ,Dua ,Tiga ,Empat ,Lima ,Enam ,Tujuh ,Delapan ,Sembilan ,Sepuluh ,Sebelas ]
DO CASE
  CASE BETWEEN(tnNum, 0, 11)
    lcTerbilang = GETWORDNUM(lcPokok, tnNum ,",")
  CASE tnNum <= 20		&& BETWEEN(tnNum, 12, 19)
    lcTerbilang = GETWORDNUM(lcPokok, (tnNum % 10) ,",") + "Belas"
  CASE tnNum < 100		&& BETWEEN(tnNum, 20, 99)
    lcTerbilang = GETWORDNUM(lcPokok, INT(tnNum / 10) ,",") + "Puluh " + GETWORDNUM(lcPokok, (tnNum % 10) ,",")
  CASE tnNum < 200		&& BETWEEN(tnNum, 100, 199)
    lcTerbilang = "Seratus " + Terbilang(tnNum - 100)
  CASE tnNum < 1000		&& BETWEEN(tnNum, 200, 999)
    lcTerbilang = Terbilang(INT(tnNum/100)) +"Ratus " + Terbilang(tnNum % 100)
  CASE tnNum < 2000		&& BETWEEN(tnNum, 1000, 1999)
    lcTerbilang = "Seribu " + Terbilang(tnNum - 1000)
  CASE tnNum < 1000000	&& BETWEEN(tnNum, 2000, 999999)
    lcTerbilang = Terbilang(INT(tnNum/1000)) +"Ribu " + Terbilang(tnNum % 1000)
  CASE tnNum < 1e9	&& BETWEEN(tnNum, 1000000, 999999999)
    lcTerbilang = Terbilang(INT(tnNum/1000000)) +"Juta " + Terbilang(tnNum % 1000000)
  CASE tnNum < 1e12
    lcTerbilang = Terbilang(INT(tnNum/1e9)) +"Milyar " + Terbilang(tnNum % 1e9)
  CASE tnNum < 1e15
    lcTerbilang = Terbilang(INT(tnNum/1e12)) +"Triliun " + Terbilang(tnNum % 1e12)
  CASE tnNum < 1e18
    lcTerbilang = Terbilang(INT(tnNum/1e15)) +"Quadriliun " + Terbilang(tnNum % 1e15)
  CASE tnNum < 1e21
    lcTerbilang = Terbilang(INT(tnNum/1e18)) +"Pentaliun " + Terbilang(tnNum % 1e18)
ENDCASE
RETURN lcTerbilang



ENTIRE THREAD

Convert Posted by sandeep singh @ 1/22/2014 8:54:46 AM
RE: Convert Posted by David Mustakim @ 1/22/2014 9:06:41 AM
RE: Convert Posted by Stefan Wuebbe @ 1/22/2014 9:12:36 AM
RE: Convert Posted by David Mustakim @ 1/22/2014 9:17:22 AM
RE: Convert Posted by Stefan Wuebbe @ 1/22/2014 9:28:31 AM
RE: Convert Posted by David Mustakim @ 1/22/2014 9:34:52 AM
RE: Convert Posted by Borislav Borissov @ 1/22/2014 9:59:09 AM