Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Change number(currency) to character
Message
From
21/10/2004 04:45:59
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00952600
Message ID:
00953240
Views:
14
hi,

i try with this code at myform, it works fantastic
at (thisform.text1.valu)procedure click or keypress
mamt=(thisform.text1.value)
camt=""
STORE "     ONE  TWO  THREEFOUR FIVE SIX  SEVENEIGHTNINE " TO ones
STORE "TEN      ELEVEN   TWELVE   THIRTEEN FOURTEEN FIFTEEN  SIXTEEN  "+;
      "SEVENTEENEIGHTEEN NINETEEN " TO teen
STORE "TWENTY THIRTY FORTY  FIFTY  SIXTY  SEVENTYEIGHTY NINETY" TO tens

cnum=LEFT(STR(mamt,10,2),7)

IF LEFT(cnum,1)>" "
   camt=RTRIM(SUBSTR(ones,VAL(LEFT(cnum,1))*5+1,5))+" MILLION "
ENDIF


if substr(cnum,2,1)>" "
   camt=camt + RTRIM(SUBSTR(ones,VAL(substr(cnum,2,1))*5+1,5))+" HUNDRED "
endif

* check tens of thousands and thousands
DO CASE
   CASE SUBSTR(cnum,3,1)>"1"
      camt=camt+RTRIM(SUBSTR(tens,VAL(SUBSTR(cnum,3,1))*7-13,7))
      IF SUBSTR(cnum,4,1)>"0"
         camt=camt+"-"+RTRIM(SUBSTR(ones,VAL(SUBSTR(cnum,4,1))*5+1,5))
      ENDIF
      camt=camt+" THOUSAND " 

   CASE SUBSTR(cnum,3,1)="1"
      camt=camt+RTRIM(SUBSTR(teen,VAL(SUBSTR(cnum,4,1))*9+1,9))+" THOUSAND "

   CASE SUBSTR(cnum,3,2)="00"
      camt=camt+"THOUSAND "

   CASE SUBSTR(cnum,4,1)>" "
      camt=camt+RTRIM(SUBSTR(ones,VAL(SUBSTR(cnum,4,1))*5+1,5))+" THOUSAND "
ENDCASE

* check hundreds
IF SUBSTR(cnum,5,1)>"0"
   camt=camt+RTRIM(SUBSTR(ones,VAL(SUBSTR(cnum,5,1))*5+1,5))+" HUNDRED "
ENDIF

* check tens and ones
DO CASE
   CASE SUBSTR(cnum,6,1)>"1"
      camt=camt+RTRIM(SUBSTR(tens,VAL(SUBSTR(cnum,6,1))*7-13,7))
      * to here
      IF RIGHT(cnum,1)>"0"
         camt=camt+"-"+RTRIM(SUBSTR(ones,VAL(RIGHT(cnum,1))*5+1,5))
      ENDIF

   CASE SUBSTR(cnum,6,1)="1"
      camt=camt+RTRIM(SUBSTR(teen,VAL(RIGHT(cnum,1))*9+1,9))

   CASE RIGHT(cnum,2)=" 0"
      camt="ZERO"

   OTHERWISE
      camt=camt+RTRIM(SUBSTR(ones,VAL(RIGHT(cnum,1))*5+1,5))
ENDCASE

* Convert decimal places to a string containing cents amount
**if CURR22 = "JOD"
  ** cents=RIGHT(STR(mamt,11,3),3)
   **camt=RTRIM(camt)+" AND "+cents+"/1000 ONLY"
***else
   cents=RIGHT(STR(mamt,11,2),2)
   camt=RTRIM(camt)+" AND "+cents+"/100 $ DOLLAR ONLY " 

string = SPACE(51)
length = LEN(camt)

* if length is greater than 75, the words will have to be 
*    broken up so that it will fit on the check
IF length > 51
*   counter = 74
   counter = 50

   DO WHILE .NOT. SUBSTR(camt,counter,1) $ " -"
      counter = counter - 1
   ENDDO

   * divide the word into two parts and display
   word1 = LEFT(camt,counter)+LEFT(string,51-counter)
   word2 = SUBSTR(camt,counter+1,length-counter)

ELSE
   * else word is less than or equal to 75 characters
   word1 = camt + LEFT(string,51-length)
****   @ 11,4 SAY word1
ENDIF
 thisform.text2.value=camt
RETURN
* Eof: Numwords.prg
*****************
thank.
best regards
m.qasem
Previous
Reply
Map
View

Click here to load this message in the networking platform