Click here to Skip to main content
14,357,409 members
Rate this:
Please Sign up or sign in to vote.
Hi here is the formula that i used for word conversion but in this when amount exists one crore it displays wrong value in the word format


numbervar RmVal:=0; 
numbervar Amt:=0; 
numbervar pAmt:=0; 
stringvar InWords :="Rupees "; 

Amt := tonumber({?Value} ); 


if Amt > 10000000 then RmVal := truncate(Amt/10000000); 
if Amt = 10000000 then RmVal := 1; 

   if RmVal = 1 then 
        InWords := InWords + " " + ProperCase (towords(RmVal,0)) + " crore" 
   else if RmVal > 1 then InWords := InWords + " " + ProperCase (towords(RmVal,0)) + " crores"; 



    Amt := Amt - Rmval * 10000000; 

    if Amt > 100000 then RmVal := truncate(Amt/100000); 
    if Amt = 100000 then RmVal := 1; 

    if RmVal = 1 then 
        InWords := InWords + " " + ProperCase (towords(RmVal,0)) + " lakh"
    Else
        If RmVal > 1 then InWords := InWords + " " + ProperCase (ToWords(RmVal,0)) + " Lakhs";


        Amt := Amt - Rmval * 100000; 

        if Amt > 0 then InWords := InWords + " " + ProperCase (towords(truncate(Amt),0)); 


        pAmt := (Amt - truncate(Amt)) * 100; 

        if pAmt > 0 then 
            InWords := InWords + " and " + ProperCase (towords(pAmt,0)) + " paise only" 
        else 
            InWords := InWords + " only"; 

        ProperCase(InWords)


Kindly suggest if there is any changes needed in this formula,
let me know asap
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Let's look if someone else had the same problem: "Convert Numeric Currency into Words (For INDIAN Currency Only) (Optimized)"[^].
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100