Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 13

List | Show Random | Upload | Add This to Your Site

CurrencyToText_SP (Monto , Currency , Sufijo)


Rate this function:

Average rating: 3.6 (10 votes)


Discuss this Custom Function
Ibrahim Bittar Torres, Eikonsys
http://www.eikonsys.com
Converts Numbers to Text in Spanish (up to 18 digits)
Sample Input:

Sample Output:

CurrencyToText_SP ( 200.32 ,
"pesos" , "M.N."

doscientos pesos 32/100 M.N.

Let ( [ Text = Right ( "000000000000000000" & GetAsText ( Int ( Abs


( Monto ) ) ) ; 18 ) ;
N01 = Middle ( text ; 1 ; 1 ) ;
N02 = Middle ( text ; 2 ; 1 ) ;
N03 = Middle ( text ; 3 ; 1 ) ;
N04 = Middle ( text ; 4 ; 1 ) ;
N05 = Middle ( text ; 5 ; 1 ) ;
N06 = Middle ( text ; 6 ; 1 ) ;
N07 = Middle ( text ; 7 ; 1 ) ;
N08 = Middle ( text ; 8 ; 1 ) ;
N09 = Middle ( text ; 9 ; 1 ) ;
N10 = Middle ( text ; 10 ; 1 ) ;
N11 = Middle ( text ; 11 ; 1 ) ;
N12 = Middle ( text ; 12 ; 1 ) ;
N13 = Middle ( text ; 13 ; 1 ) ;
N14 = Middle ( text ; 14 ; 1 ) ;
N15 = Middle ( text ; 15 ; 1 ) ;
N16 = Middle ( text ; 16 ; 1 ) ;

N17 = Middle ( text ; 17 ; 1 ) ;


N18 = Middle ( text ; 18 ; 1 ) ;
Decimal = Right ( "00" & ( Round ( Monto ; 2 ) - Int ( Monto ) ) * 100 ;
2)];

Trim (

//Centenas de Miles de Billn

Case ( N01 = 1 and N02 = 0 and N03 = 0 ; "cien " ;


N01 = 1 ; "ciento " ;
N01 = 2 ; "doscientos " ;
N01 = 3 ; "trescientos " ;
N01 = 4 ; "cuatrocientos " ;
N01 = 5 ; "quinientos " ;
N01 = 6 ; "seiscientos " ;
N01 = 7 ; "setecientos " ;
N01 = 8 ; "ochocientos " ;
N01 = 9 ; "novecientos " ; "" ) &

//Decenas de Miles de Billn

Case ( N02 = 1 and N03 = 0 ; "diez " ;


N02 = 1 and N03 = 1 ; "once " ;
N02 = 1 and N03 = 2 ; "doce " ;
N02 = 1 and N03 = 3 ; "trece " ;
N02 = 1 and N03 = 4 ; "catorce " ;
N02 = 1 and N03 = 5 ; "quince " ;
N02 = 2 and N03 = 0 ; "veinte " ;

N02 = 3 and N03 = 0 ; "treinta " ;


N02 = 4 and N03 = 0 ; "cuarenta " ;
N02 = 5 and N03 = 0 ; "cincuenta " ;
N02 = 6 and N03 = 0 ; "sesenta " ;
N02 = 7 and N03 = 0 ; "setenta " ;
N02 = 8 and N03 = 0 ; "ochenta " ;
N02 = 9 and N03 = 0 ; "noventa " ;
N02 = 1 ; "dieci" ;
N02 = 2 ; "veinti" ;
N02 = 3 ; "treinta y " ;
N02 = 4 ; "cuarenta y " ;
N02 = 5 ; "cincuenta y " ;
N02 = 6 ; "sesenta y " ;
N02 = 7 ; "setenta y " ;
N02 = 8 ; "ochenta y " ;
N02 = 9 ; "noventa y " ; "" ) &

//Unidades de Miles de Billn

Case ( N03 = 1 and N02 > 1 ; "un " ;


N03 = 1 and N02 = 0 ; "un " ;
N03 = 2 and ( N02 > 1 or N02 = 0 ) ; "dos " ;
N03 = 3 and ( N02 > 1 or N02 = 0 ) ; "tres " ;
N03 = 4 and ( N02 > 1 or N02 = 0 ) ; "cuatro " ;
N03 = 5 and ( N02 > 1 or N02 = 0 ) ; "cinco " ;
N03 = 6 ; "seis " ;
N03 = 7 ; "siete " ;
N03 = 8 ; "ocho " ;

N03 = 9 ; "nueve " ; "" ) &

If ( N01 > 0 or N02 > 0 or N03 > 0 ; "mil " ; "" ) &

//Centenas de Billn

Case ( N04 = 1 and N05 = 0 and N06 = 0 ; "cien " ;


N04 = 1 ; "ciento " ;
N04 = 2 ; "doscientos " ;
N04 = 3 ; "trescientos " ;
N04 = 4 ; "cuatrocientos " ;
N04 = 5 ; "quinientos " ;
N04 = 6 ; "seiscientos " ;
N04 = 7 ; "setecientos " ;
N04 = 8 ; "ochocientos " ;
N04 = 9 ; "novecientos " ; "" ) &

//Decenas de Miles de Billn

Case ( N05 = 1 and N06 = 0 ; "diez " ;


N05 = 1 and N06 = 1 ; "once " ;
N05 = 1 and N06 = 2 ; "doce " ;
N05 = 1 and N06 = 3 ; "trece " ;
N05 = 1 and N06 = 4 ; "catorce " ;
N05 = 1 and N06 = 5 ; "quince " ;
N05 = 2 and N06 = 0 ; "veinte " ;
N05 = 3 and N06 = 0 ; "treinta " ;
N05 = 4 and N06 = 0 ; "cuarenta " ;

N05 = 5 and N06 = 0 ; "cincuenta " ;


N05 = 6 and N06 = 0 ; "sesenta " ;
N05 = 7 and N06 = 0 ; "setenta " ;
N05 = 8 and N06 = 0 ; "ochenta " ;
N05 = 9 and N06 = 0 ; "noventa " ;
N05 = 1 ; "dieci" ;
N05 = 2 ; "veinti" ;
N05 = 3 ; "treinta y " ;
N05 = 4 ; "cuarenta y " ;
N05 = 5 ; "cincuenta y " ;
N05 = 6 ; "sesenta y " ;
N05 = 7 ; "setenta y " ;
N05 = 8 ; "ochenta y " ;
N05 = 9 ; "noventa y " ; "" ) &

//Unidades de Billn

Case ( N06 = 1 and N05 > 1 ; "un " ;


N06 = 1 and N05 = 0 ; "un " ;
N06 = 2 and ( N05 > 1 or N05 = 0 ) ; "dos " ;
N06 = 3 and ( N05 > 1 or N05 = 0 ) ; "tres " ;
N06 = 4 and ( N05 > 1 or N05 = 0 ) ; "cuatro " ;
N06 = 5 and ( N05 > 1 or N05 = 0 ) ; "cinco " ;
N06 = 6 ; "seis " ;
N06 = 7 ; "siete " ;
N06 = 8 ; "ocho " ;
N06 = 9 ; "nueve " ; "" ) &

Case ( N01 = 0 and N02 = 0 and N03 = 0 and N04 = 0 and N05 = 0 and
N06 = 0 ; "" ;
N01 = 0 and N02 = 0 and N03 = 0 and N04 = 0 and N05 = 0 and N06
= 1 ; "billn" ; "billones" ) & " " &

//Centenas de Miles de Milln

Case ( N07 = 1 and N08 = 0 and N09 = 0 ; "cien " ;


N07 = 1 ; "ciento " ;
N07 = 2 ; "doscientos " ;
N07 = 3 ; "trescientos " ;
N07 = 4 ; "cuatrocientos " ;
N07 = 5 ; "quinientos " ;
N07 = 6 ; "seiscientos " ;
N07 = 7 ; "setecientos " ;
N07 = 8 ; "ochocientos " ;
N07 = 9 ; "novecientos " ; "" ) &

//Decenas de Miles de Milln

Case ( N08 = 1 and N09 = 0 ; "diez " ;


N08 = 1 and N09 = 1 ; "once " ;
N08 = 1 and N09 = 2 ; "doce " ;
N08 = 1 and N09 = 3 ; "trece " ;
N08 = 1 and N09 = 4 ; "catorce " ;
N08 = 1 and N09 = 5 ; "quince " ;
N08 = 2 and N09 = 0 ; "veinte " ;
N08 = 3 and N09 = 0 ; "treinta " ;
N08 = 4 and N09 = 0 ; "cuarenta " ;

N08 = 5 and N09 = 0 ; "cincuenta " ;


N08 = 6 and N09 = 0 ; "sesenta " ;
N08 = 7 and N09 = 0 ; "setenta " ;
N08 = 8 and N09 = 0 ; "ochenta " ;
N08 = 9 and N09 = 0 ; "noventa " ;
N08 = 1 ; "dieci" ;
N08 = 2 ; "veinti" ;
N08 = 3 ; "treinta y " ;
N08 = 4 ; "cuarenta y " ;
N08 = 5 ; "cincuenta y " ;
N08 = 6 ; "sesenta y " ;
N08 = 7 ; "setenta y " ;
N08 = 8 ; "ochenta y " ;
N08 = 9 ; "noventa y " ; "" ) &

//Unidades de Miles de Milln

Case ( N09 = 1 and N08 > 1 ; "un " ;


N09 = 1 and N08 = 0 ; "un " ;
N09 = 2 and ( N08 > 1 or N08 = 0 ) ; "dos " ;
N09 = 3 and ( N08 > 1 or N08 = 0 ) ; "tres " ;
N09 = 4 and ( N08 > 1 or N08 = 0 ) ; "cuatro " ;
N09 = 5 and ( N08 > 1 or N08 = 0 ) ; "cinco " ;
N09 = 6 ; "seis " ;
N09 = 7 ; "siete " ;
N09 = 8 ; "ocho " ;
N09 = 9 ; "nueve " ; "" ) &

If ( N07 > 0 or N08 > 0 or N09 > 0 ; "mil " ; "" ) &

//Centenas de Milln

Case ( N10 = 1 and N11 = 0 and N12 = 0 ; "cien " ;


N10 = 1 ; "ciento " ;
N10 = 2 ; "doscientos " ;
N10 = 3 ; "trescientos " ;
N10 = 4 ; "cuatrocientos " ;
N10 = 5 ; "quinientos " ;
N10 = 6 ; "seiscientos " ;
N10 = 7 ; "setecientos " ;
N10 = 8 ; "ochocientos " ;
N10 = 9 ; "novecientos " ; "" ) &

//Decenas de Milln

Case ( N11 = 1 and N12 = 0 ; "diez " ;


N11 = 1 and N12 = 1 ; "once " ;
N11 = 1 and N12 = 2 ; "doce " ;
N11 = 1 and N12 = 3 ; "trece " ;
N11 = 1 and N12 = 4 ; "catorce " ;
N11 = 1 and N12 = 5 ; "quince " ;
N11 = 2 and N12 = 0 ; "veinte " ;
N11 = 3 and N12 = 0 ; "treinta " ;
N11 = 4 and N12 = 0 ; "cuarenta " ;
N11 = 5 and N12 = 0 ; "cincuenta " ;
N11 = 6 and N12 = 0 ; "sesenta " ;

N11 = 7 and N12 = 0 ; "setenta " ;


N11 = 8 and N12 = 0 ; "ochenta " ;
N11 = 9 and N12 = 0 ; "noventa " ;
N11 = 1 ; "dieci" ;
N11 = 2 ; "veinti" ;
N11 = 3 ; "treinta y " ;
N11 = 4 ; "cuarenta y " ;
N11 = 5 ; "cincuenta y " ;
N11 = 6 ; "sesenta y " ;
N11 = 7 ; "setenta y " ;
N11 = 8 ; "ochenta y " ;
N11 = 9 ; "noventa y " ; "" ) &

//Unidades de Milln

Case ( N12 = 1 and N11 > 1 ; "un " ;


N12 = 1 and N11 = 0 ; "un " ;
N12 = 2 and ( N11 > 1 or N11 = 0 ) ; "dos " ;
N12 = 3 and ( N11 > 1 or N11 = 0 ) ; "tres " ;
N12 = 4 and ( N11 > 1 or N11 = 0 ) ; "cuatro " ;
N12 = 5 and ( N11 > 1 or N11 = 0 ) ; "cinco " ;
N12 = 6 ; "seis " ;
N12 = 7 ; "siete " ;
N12 = 8 ; "ocho " ;
N12 = 9 ; "nueve " ; "" ) &

Case ( N07 = 0 and N08 = 0 and N09 = 0 and N10 = 0 and N11 = 0 and
N12 = 0 ; "" ;

N07 = 0 and N08 = 0 and N09 = 0 and N10 = 0 and N11 = 0 and N12
= 1 ; "milln" ; "millones" ) & " " &

//Centenas de Mil

Case ( N13 = 1 and N14 = 0 and N15 = 0 ; "cien " ;


N13 = 1 ; "ciento " ;
N13 = 2 ; "doscientos " ;
N13 = 3 ; "trescientos " ;
N13 = 4 ; "cuatrocientos " ;
N13 = 5 ; "quinientos " ;
N13 = 6 ; "seiscientos " ;
N13 = 7 ; "setecientos " ;
N13 = 8 ; "ochocientos " ;
N13 = 9 ; "novecientos " ; "" ) &

//Decenas de Mil

Case ( N14 = 1 and N15 = 0 ; "diez " ;


N14 = 1 and N15 = 1 ; "once " ;
N14 = 1 and N15 = 2 ; "doce " ;
N14 = 1 and N15 = 3 ; "trece " ;
N14 = 1 and N15 = 4 ; "catorce " ;
N14 = 1 and N15 = 5 ; "quince " ;
N14 = 2 and N15 = 0 ; "veinte " ;
N14 = 3 and N15 = 0 ; "treinta " ;
N14 = 4 and N15 = 0 ; "cuarenta " ;
N14 = 5 and N15 = 0 ; "cincuenta " ;
N14 = 6 and N15 = 0 ; "sesenta " ;

N14 = 7 and N15 = 0 ; "setenta " ;


N14 = 8 and N15 = 0 ; "ochenta " ;
N14 = 9 and N15 = 0 ; "noventa " ;
N14 = 1 ; "dieci" ;
N14 = 2 ; "veinti" ;
N14 = 3 ; "treinta y " ;
N14 = 4 ; "cuarenta y " ;
N14 = 5 ; "cincuenta y " ;
N14 = 6 ; "sesenta y " ;
N14 = 7 ; "setenta y " ;
N14 = 8 ; "ochenta y " ;
N14 = 9 ; "noventa y " ; "" ) &

//Unidades de Mil

Case ( N15 = 1 and N14 > 1 ; "un " ;


N15 = 1 and N14 = 0 ; "un " ;
N15 = 2 and ( N14 > 1 or N14 = 0 ) ; "dos " ;
N15 = 3 and ( N14 > 1 or N14 = 0 ) ; "tres " ;
N15 = 4 and ( N14 > 1 or N14 = 0 ) ; "cuatro " ;
N15 = 5 and ( N14 > 1 or N14 = 0 ) ; "cinco " ;
N15 = 6 ; "seis " ;
N15 = 7 ; "siete " ;
N15 = 8 ; "ocho " ;
N15 = 9 ; "nueve " ; "" ) &

If ( N13 > 0 or N14 > 0 or N15 > 0 ; "mil " ; "" ) &

//Centenas

Case ( N16 = 1 and N17 = 0 and N18 = 0 ; "cien " ;


N16 = 1 ; "ciento " ;
N16 = 2 ; "doscientos " ;
N16 = 3 ; "trescientos " ;
N16 = 4 ; "cuatrocientos " ;
N16 = 5 ; "quinientos " ;
N16 = 6 ; "seiscientos " ;
N16 = 7 ; "setecientos " ;
N16 = 8 ; "ochocientos " ;
N16 = 9 ; "novecientos " ; "" ) &

//Decenas

Case ( N17 = 1 and N18 = 0 ; "diez " ;


N17 = 1 and N18 = 1 ; "once " ;
N17 = 1 and N18 = 2 ; "doce " ;
N17 = 1 and N18 = 3 ; "trece " ;
N17 = 1 and N18 = 4 ; "catorce " ;
N17 = 1 and N18 = 5 ; "quince " ;
N17 = 2 and N18 = 0 ; "veinte " ;
N17 = 3 and N18 = 0 ; "treinta " ;
N17 = 4 and N18 = 0 ; "cuarenta " ;
N17 = 5 and N18 = 0 ; "cincuenta " ;
N17 = 6 and N18 = 0 ; "sesenta " ;
N17 = 7 and N18 = 0 ; "setenta " ;
N17 = 8 and N18 = 0 ; "ochenta " ;

N17 = 9 and N18 = 0 ; "noventa " ;


N17 = 1 ; "dieci" ;
N17 = 2 ; "veinti" ;
N17 = 3 ; "treinta y " ;
N17 = 4 ; "cuarenta y " ;
N17 = 5 ; "cincuenta y " ;
N17 = 6 ; "sesenta y " ;
N17 = 7 ; "setenta y " ;
N17 = 8 ; "ochenta y " ;
N17 = 9 ; "noventa y " ; "" ) &

//Unidades

Case ( N18 = 1 and N17 > 1 ; "un " ;


N18 = 1 and N17 = 0 ; "un " ;
N18 = 2 and ( N17 > 1 or N17 = 0 ) ; "dos " ;
N18 = 3 and ( N17 > 1 or N17 = 0 ) ; "tres " ;
N18 = 4 and ( N17 > 1 or N17 = 0 ) ; "cuatro " ;
N18 = 5 and ( N17 > 1 or N17 = 0 ) ; "cinco " ;
N18 = 6 ; "seis " ;
N18 = 7 ; "siete " ;
N18 = 8 ; "ocho " ;
N18 = 9 ; "nueve " ; "" ) &

If ( Int ( Monto ) = 0 ; "cero " ; "" ) &

Currency & " " & Decimal & "/100 " & Sufijo ) )

You might also like