FoxPro/How Amount in figures convert to Amount in words
Expert: Markish - 9/15/2008
QuestionI 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
AnswerHi 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