Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert dollar digits to words on checks
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Novell 6.x
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01058528
Message ID:
01058765
Views:
15
This message has been marked as the solution to the initial question of the thread.
>Greetings all
>Does anyone have or no of a class or subroutine that, when passed dollar and cent digits returns a string with the quivalent dollar amount in words for checks?
>Ex: send: 13.26
> return: thirteen dollars and 26/100 **************
>
>Thanks, Vince
FUNCTION Amt2Words
	PARAMETER nTrAmt

    lThousands  = nTrAmt >= 1000
    gcAmtStr     = STR(nTrAmt,9,2)
    gcOneStr     = 'One      Two      Three    Four     Five     Six      Seven    Eight    Nine     Ten      Eleven   Twelve   Thirteen Fourteen Fifteen  Sixteen  SeventeenEighteen Nineteen'
    gcTenStr     = 'Twenty Thirty Forty  Fifty  Sixty  SeventyEighty Ninety'
    cAmtInWords = ''

    IF lThousands
        IF DigitValue(1,1) > 0
            Add2WordStr(SUBSTR(gcOneStr,DigitValue(1,1)*9-8,9))
            Add2WordStr('Hundred')
        ENDIF
        IF DigitValue(2,1) > 1
            Add2WordStr(SUBSTR(gcTenStr,(DigitValue(2,1)-1)*7-6,7))
            IF DigitValue(3,1) > 0
                Add2WordStr(SUBSTR(gcOneStr,DigitValue(3,1)*9-8,9))
            ENDIF
        ELSE
            IF DigitValue(2,2) > 0
                Add2WordStr(SUBSTR(gcOneStr,DigitValue(2,2)*9-8,9))
            ENDIF
        ENDIF
        Add2WordStr('Thousand')
    ENDIF

    IF DigitValue(4,1) > 0
        Add2WordStr(SUBSTR(gcOneStr,DigitValue(4,1)*9-8,9))
        Add2WordStr('Hundred')
    ENDIF

    IF DigitValue(5,1) > 1
        Add2WordStr(SUBSTR(gcTenStr,(DigitValue(5,1)-1)*7-6,7))
        IF DigitValue(6,1) > 0
            Add2WordStr(SUBSTR(gcOneStr,DigitValue(6,1)*9-8,9))
        ENDIF
    ELSE
        IF DigitValue(5,2) > 0
            Add2WordStr(SUBSTR(gcOneStr,DigitValue(5,2)*9-8,9))
        ENDIF
    ENDIF
    IF nTrAmt = 0
        cAmtInWords = 'Zero '
    ENDIF
    cAmtInWords = cAmtInWords + 'dollars and ' + SUBSTR(gcAmtStr,8,2) + ' cents ' + REPLICATE('*',80)
RETURN cAmtInWords
 
FUNCTION DigitValue   
	PARAMETER mPOS,mLEN
RETURN VAL(SUBSTR(gcAmtStr,mPOS,mLEN))

FUNCTION Add2WordStr  
	PARAMETER mSTRING
    cAmtInWords = cAmtInWords + ALLTRIM(mSTRING)+' '
RETURN .T.
ICQ 10556 (ya), 254117
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform