numeros -> letras
mis amigos, revisando un poco los foros, me di cuenta que en varias ocaciones han pedido la opcion de transformar números a letras, bueno aqui tengo la solución
la única observación es que el text1 debe tener un imput mask de 999,999,999.99 y su value debe ser cero "0"
bueno aqui les va el código:
Parameter numero,uni,dec,cen
numero=(thisform.text1.value)
num_car = Str(numero,15,2)
num_dig = Subs(num_car,14,2)
pos = 1
Store "" To num_car_fin,leyenda
***
For t=1 To 4
Store 0 To uni,dec,cen
cen = Val(Subs(num_car,pos+0,1))
dec = Val(Subs(num_car,pos+1,1))
uni = Val(Subs(num_car,pos+2,1))
pos = pos + 3
*** Unidades
Do Case
Case uni = 1 .And. dec#1
ctextoU = "Un "
Case uni = 2 .And. dec#1
ctextoU = "Dos "
Case uni = 3 .And. dec#1
ctextoU = "Tres "
Case uni = 4 .And. dec#1
ctextoU = "Cuatro "
Case uni = 5 .And. dec#1
ctextoU = "Cinco "
Case uni = 6
ctextoU = "Seis "
Case uni = 7
ctextoU = "Siete "
Case uni = 8
ctextoU = "Ocho "
Case uni = 9
ctextoU = "Nueve "
OtherWise
ctextoU = ""
EndCase
*** Decenas
Do Case
Case dec=1 .and. uni=0
ctextoD = "Diez "
Case dec=1 .and. uni=1
ctextoD = "Once "
Case dec=1 .and. uni=2
ctextoD = "Doce "
Case dec=1 .and. uni=3
ctextoD = "Trece "
Case dec=1 .and. uni=4
ctextoD = "Catorce "
Case dec=1 .and. uni=5
ctextoD = "Quince "
Case dec=1 .and. (uni>5 .and. uni<10)
ctextoD = "Dieci"
Case dec=2 .and. uni=0
ctextoD = "Veinte "
Case dec=2 .and. uni>0
ctextoD = "Veinti"
Case dec=3 .and. uni=0
ctextoD = "Treinta "
Case dec=3 .and. uni>0
ctextoD = "Treinta y "
Case dec=4 .and. uni=0
ctextoD = "Cuarenta "
Case dec=4 .and. uni>0
ctextoD = "Cuarenta y "
Case dec=5 .and. uni=0
ctextoD = "Cincuenta "
Case dec=5 .and. uni>0
ctextoD = "Cincuenta y "
Case dec=6 .and. uni=0
ctextoD = "Sesenta "
Case dec=6 .and. uni>0
ctextoD = "Sesenta y "
Case dec=7 .and. uni=0
ctextoD = "Setenta "
Case dec=7 .and. uni>0
ctextoD = "Setenta y "
Case dec=8 .and. uni=0
ctextoD = "Ochenta "
Case dec=8 .and. uni>0
ctextoD = "Ochenta y "
Case dec=9 .and. uni=0
ctextoD = "Noventa "
Case dec=9 .and. uni>0
ctextoD = "Noventa y "
OtherWise
ctextoD = ""
EndCase
*** Centenas
Do Case
Case cen=1 .And. (dec=0 .And. uni=0)
ctextoC = "Cien "
Case cen=1 .And. (dec>0 .Or. uni>0)
ctextoC = "Ciento "
Case cen=2
ctextoC = "Doscientos "
Case cen=3
ctextoC = "Trescientos "
Case cen=4
ctextoC = "Cuatrocientos "
Case cen=5
ctextoC = "Quinientos "
Case cen=6
ctextoC = "Seiscientos "
Case cen=7
ctextoC = "Setecientos "
Case cen=8
ctextoC = "Ochocientos "
Case cen=9
ctextoC = "Novecientos "
OtherWise
ctextoC = ""
EndCase
************************************* PARA LAS VARIABLES *****************************
letra3 = ctextoC && CENTENAS
letra2 = ctextoD && DECENAS
letra1 = ctextoU && UNIDADES
************************************** OJO *******************************************
Do Case
Case t=1
leyenda = IIf(uni+dec+cen=1,"billon ",IIf(uni+dec+cen>1,"billones ",""))
Case t=2
leyenda = IIf(uni+dec+cen=1,"millon ",IIf(uni+dec+cen>1,"millones ",""))
Case t=3
leyenda = IIf(uni+dec+cen=1,"mil ",IIf(uni+dec+cen>1,"mil ",""))
Case t=4
leyenda = IIf(uni+dec+cen=1,"",IIf(uni+dec+cen>1,"",""))
EndCase
num_car_fin = num_car_fin + letra3 + letra2 + letra1 + leyenda
EndFor
***
num_1 = Val(Subs(num_car,1,12))
num_2 = Val(Subs(num_car,4,9))
num_3 = Val(Subs(num_car,7,6))
leyenda = ""
If num_1=1
leyenda = " Bolivares "
Else
If num_2=0 .Or. num_3=0
leyenda = " de Bolivares "
Else
leyenda = " Bolivares "
EndIf
EndIf
If num_1 = 0
num_car_fin = "Cero "
leyenda = "Bolivares "
EndIf
num_car_fin = num_car_fin + leyenda +", "+ num_dig + "/100"
***
thisform.text2.value=num_car_fin
la única observación es que el text1 debe tener un imput mask de 999,999,999.99 y su value debe ser cero "0"
bueno aqui les va el código:
Parameter numero,uni,dec,cen
numero=(thisform.text1.value)
num_car = Str(numero,15,2)
num_dig = Subs(num_car,14,2)
pos = 1
Store "" To num_car_fin,leyenda
***
For t=1 To 4
Store 0 To uni,dec,cen
cen = Val(Subs(num_car,pos+0,1))
dec = Val(Subs(num_car,pos+1,1))
uni = Val(Subs(num_car,pos+2,1))
pos = pos + 3
*** Unidades
Do Case
Case uni = 1 .And. dec#1
ctextoU = "Un "
Case uni = 2 .And. dec#1
ctextoU = "Dos "
Case uni = 3 .And. dec#1
ctextoU = "Tres "
Case uni = 4 .And. dec#1
ctextoU = "Cuatro "
Case uni = 5 .And. dec#1
ctextoU = "Cinco "
Case uni = 6
ctextoU = "Seis "
Case uni = 7
ctextoU = "Siete "
Case uni = 8
ctextoU = "Ocho "
Case uni = 9
ctextoU = "Nueve "
OtherWise
ctextoU = ""
EndCase
*** Decenas
Do Case
Case dec=1 .and. uni=0
ctextoD = "Diez "
Case dec=1 .and. uni=1
ctextoD = "Once "
Case dec=1 .and. uni=2
ctextoD = "Doce "
Case dec=1 .and. uni=3
ctextoD = "Trece "
Case dec=1 .and. uni=4
ctextoD = "Catorce "
Case dec=1 .and. uni=5
ctextoD = "Quince "
Case dec=1 .and. (uni>5 .and. uni<10)
ctextoD = "Dieci"
Case dec=2 .and. uni=0
ctextoD = "Veinte "
Case dec=2 .and. uni>0
ctextoD = "Veinti"
Case dec=3 .and. uni=0
ctextoD = "Treinta "
Case dec=3 .and. uni>0
ctextoD = "Treinta y "
Case dec=4 .and. uni=0
ctextoD = "Cuarenta "
Case dec=4 .and. uni>0
ctextoD = "Cuarenta y "
Case dec=5 .and. uni=0
ctextoD = "Cincuenta "
Case dec=5 .and. uni>0
ctextoD = "Cincuenta y "
Case dec=6 .and. uni=0
ctextoD = "Sesenta "
Case dec=6 .and. uni>0
ctextoD = "Sesenta y "
Case dec=7 .and. uni=0
ctextoD = "Setenta "
Case dec=7 .and. uni>0
ctextoD = "Setenta y "
Case dec=8 .and. uni=0
ctextoD = "Ochenta "
Case dec=8 .and. uni>0
ctextoD = "Ochenta y "
Case dec=9 .and. uni=0
ctextoD = "Noventa "
Case dec=9 .and. uni>0
ctextoD = "Noventa y "
OtherWise
ctextoD = ""
EndCase
*** Centenas
Do Case
Case cen=1 .And. (dec=0 .And. uni=0)
ctextoC = "Cien "
Case cen=1 .And. (dec>0 .Or. uni>0)
ctextoC = "Ciento "
Case cen=2
ctextoC = "Doscientos "
Case cen=3
ctextoC = "Trescientos "
Case cen=4
ctextoC = "Cuatrocientos "
Case cen=5
ctextoC = "Quinientos "
Case cen=6
ctextoC = "Seiscientos "
Case cen=7
ctextoC = "Setecientos "
Case cen=8
ctextoC = "Ochocientos "
Case cen=9
ctextoC = "Novecientos "
OtherWise
ctextoC = ""
EndCase
************************************* PARA LAS VARIABLES *****************************
letra3 = ctextoC && CENTENAS
letra2 = ctextoD && DECENAS
letra1 = ctextoU && UNIDADES
************************************** OJO *******************************************
Do Case
Case t=1
leyenda = IIf(uni+dec+cen=1,"billon ",IIf(uni+dec+cen>1,"billones ",""))
Case t=2
leyenda = IIf(uni+dec+cen=1,"millon ",IIf(uni+dec+cen>1,"millones ",""))
Case t=3
leyenda = IIf(uni+dec+cen=1,"mil ",IIf(uni+dec+cen>1,"mil ",""))
Case t=4
leyenda = IIf(uni+dec+cen=1,"",IIf(uni+dec+cen>1,"",""))
EndCase
num_car_fin = num_car_fin + letra3 + letra2 + letra1 + leyenda
EndFor
***
num_1 = Val(Subs(num_car,1,12))
num_2 = Val(Subs(num_car,4,9))
num_3 = Val(Subs(num_car,7,6))
leyenda = ""
If num_1=1
leyenda = " Bolivares "
Else
If num_2=0 .Or. num_3=0
leyenda = " de Bolivares "
Else
leyenda = " Bolivares "
EndIf
EndIf
If num_1 = 0
num_car_fin = "Cero "
leyenda = "Bolivares "
EndIf
num_car_fin = num_car_fin + leyenda +", "+ num_dig + "/100"
***
thisform.text2.value=num_car_fin
hola, por casualidad tendrias la misma rutina pero para sql*plus, tengo que hacerlo sobre un base de datos 9i, si tienes algo me puedes ayudar
de ante mano gracias.
mi correo es [email protected]
de ante mano gracias.
mi correo es [email protected]
