number2TextConverter.cfc
This is a component that takes a number as an argument and returns a string representation of that number. It can convert numbers in the range from 1 to 999999999.
// Create an object
c = new number2TextConverter();
// Change language
c.setLanguage('spanish');
// Change the currency
c.setCurrency( 'MX' );
// Converting just the number
result = c.convert( 1999 ); // mil novecientos noventa y nueve
// Converting the number and adding the currency at the end
result = c.convert( 1999.50, true ); // mil novecientos novena y nueve 50/100 MX
c.setCurrency( 'pesos' );
result = c.convert( 1999.50, true ); //mil novecientos novena y nueve 50/100 pesos
//Language can be changed without creating another object just call setLanguage function
c.setLanguage('english');
c.setCurrency('USD');
result = c.convert( 1999 ); //one thousand nine hundred and ninetynine
result = c.convert( 1999, true ); //one thousand nine hundred and ninetynine USD
c.setCurrency( 'dollars' );
result = c.convert( 1999.50, true ); //one thousand nine hundred and ninetynine 50/100 dollars
0 comments on Number to Text Converter