Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Iam using the below code to print amount in words in crystal report. When i convert 2077676 to words this return TWO MILLION SEVENTY SEVEN THOUSAND SIX HUNDRED SEVENTY SIX. But I want TWENTY LAC SEVENTY SEVEN THOUSAND SIX HUNDRED SEVENTY SIX
.How can i do this



VB
dim mIntPart as number, mDecPart as number
dim mAmtInWords as string
mintpart=int({qryFilingRebateClaim.InvExc_DutyRate})
mDecpart = {qryFilingRebateClaim.InvExc_DutyRate} - int({qryFilingRebateClaim.InvExc_DutyRate})
mAmtInWords=Towords(mIntPart)
mAmtInWords=left(mAmtInWords,instr(mAmtInWords," and"))
if mDecpart <> 0 then
    mAmtInWords=mAmtInWords + " POINT " + Towords(mDecpart*10)
    mAmtInWords=left(mAmtInWords,instr(mAmtInWords," and"))
end if
mAmtInWords = ucase(mAmtInWords) + " ONLY"
formula=mAmtInWords
Posted
Comments
Jaganathan Bantheswaran 20-Jan-12 7:39am    
You need to change the ToWords method logic
Member 8390746 21-Jan-12 0:36am    
ToWords is a builtin function

1 solution

The link below links to an OpenOffice document with Macro's (with credits to Andrew Pitonyak who wrote it). On page 81 of this document you'll find the listing to do exactly what you want. It shouldn't be to hard converting it because it is already VBA compatible. The function goes as far as a centillion which should be good enough for a couple more years ;)
Personally I find this version very clean and compact, especially as it also works with numbers insanely larger than other examples. Really something worthy of having a look at.

http://www.google.nl/url?sa=t&rct=j&q=openoffice%20macro%20number%20to%20words&source=web&cd=2&ved=0CDEQFjAB&url=http%3A%2F%2Fwww.openoffice.org%2Fdocumentation%2FHOW_TO%2Fvarious_topics%2FAndrewMacro.odt&ei=pV8ZT_y1EsvTsgbsv-hI&usg=AFQjCNEUbb8iQhGd9-ITRrzXmKF1ohK9Cg&cad=rja[^]

Good luck!
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900