AllExperts > FoxPro 
Search      
FoxPro
Volunteer
Answers to thousands of questions
 Home · More FoxPro Questions · Answer Library  · Encyclopedia ·
More FoxPro Answers
Question Library

Ask a question about FoxPro
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Markish
Expertise
I can answer general questions related to Foxpro from Version 2.0 to 9.0. I'll try to answer them as quickly as possible.

Experience
I've been into Dbase programming from age of 11. I've worked in versions from FoxPro 2.0 and Foxbase.
Education/Credentials
I've done my B.Tech (IT) with distinction from Anna University, Chennai - India.

 
   

You are here:  Experts > Computing/Technology > Databases > FoxPro > How Amount in figures convert to Amount in words

FoxPro - How Amount in figures convert to Amount in words


Expert: Markish - 9/15/2008

Question
I am using Visual foxpro6.0 . My question is, suppose a field on a .dbf file contains amount in figures. How can I display any AMOUNT IN FIGURES to AMOUNT IN WORDS

Thanking you,
Diplab

Answer
Hi Diplab,
   AFAIK there is no direct function in VFP / FoxPro for this. But you can achive this via coding.

You can use this function like below

Para xxx
n01='One'
n02='Two'
n03='Three'
n04='Four'
n05='Five'
n06='Six'
n07='Seven'
n08='Eight'
n09='Nine'
n10='Ten'
n11='Eleven'
n12='Twelve'
n13='Thirteen'
n14='Fourteen'
n15='Fifteen'
n16='Sixteen'
n17='Seventeen'
n18='Eighteen'
n19='Ninteen'
n20='Twenty'
n30='Thirty'
n40='Forty'
n50='Fifty'
n60='Sixty'
n70='Seventy'
n80='Eighty'
n90='Ninety'
For ii=1 To 10
  s1=Substr(Str(ii+100,3),2,2)
  m&s1=Substr(Str(Abs(xxx),10,2),ii,1)
Next ii
ct=0
If (m01#' ' And m01#'0') Or (m02#' ' And m02#'0')
  ct=ct+1
  s1=Str(ct,1)
  If m01#' ' And m01#'0'
     If m01='1' Or m02='0'
        x1=m01+m02
        wd&s1=N&x1+' Lakhs '
     Else
        x1=m01+'0'
        x2='0'+m02
        wd&s1=N&x1+' '+N&x2+' Lakhs '
     Endif
  Else
     x1='0'+m02
     If x1='01'
        wd&s1=N&x1+' Lakh '
     Else
        wd&s1=N&x1+' Lakhs '
     Endif
  Endif
Endif
If (m03#' ' And m03#'0') Or (m04#' ' And m04#'0')
  ct=ct+1
  s1=Str(ct,1)
  If m03#' ' And m03#'0'
     If m03='1' Or m04='0'
        wd&s1=N&m03&m04+' Thousand '
     Else
        x1=m03+'0'
        x2='0'+m04
        wd&s1=N&x1+' '+N&x2+' Thousand '
     Endif
  Else
     x1='0'+m04
     wd&s1=N&x1+' Thousand '
  Endif
Endif
If m05#' ' And m05#'0'
  ct=ct+1
  s1=Str(ct,1)
  x1='0'+m05
  wd&s1=N&x1+' Hundred '
Endif
If (m06#' ' And m06#'0') Or (m07#' ' And m07#'0')
  ct=ct+1
  s1=Str(ct,1)
  If ct#1
     wd&s1='and '
  Else
     wd&s1=''
  Endif
  If m06#' ' And m06#'0'
     If m06='1' Or m07='0'
        wd&s1=wd&s1+N&m06&m07+' '
     Else
        x1=m06+'0'
        x2='0'+m07
        wd&s1=wd&s1+N&x1+' '+N&x2+' '
     Endif
  Else
     x1='0'+m07
     wd&s1=wd&s1+N&x1+' '
  Endif
Endif
If (m09#' ' And m09#'0') Or (m10#' ' And m10#'0')
  ct=ct+1
  s1=
  Str(ct,1)
  wd&s1='And Paise '
  If m09#' ' And m09#'0'
     If m09='1' Or m10='0'
        wd&s1=wd&s1+N&m09&m10
     Else
        x1=m09+'0'
        x2='0'+m10
        wd&s1=wd&s1+N&x1+' '+N&x2
     Endif
  Else
     x1='0'+m10
     wd&s1=wd&s1+N&x1
  Endif
Endif
Word='Rupees '
xx=1
Do Whil xx<=ct
  s1=Str(xx,1)
  Word=Word+wd&s1
  xx=xx+1
Enddo
Word=Word+' Only'
Return Word


Then you can call this function with a number like

? toword(10383)

Hope this helps...

Best regards,
Markish
http://markishonline.com


Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.