Portal    Foro    Buscar    FAQ    Registrarse    Conectarse


Publicar nuevo tema  Responder al tema 
Página 1 de 1
 
 
Aplicacion Para Convertir Numeros A Letras
Autor Mensaje
Responder citando   Descargar mensaje  
Mensaje Aplicacion Para Convertir Numeros A Letras 
 
Hola a todos.

Os paso una aplicación para convertir numeros a letras y escucharlos.

http://jsbsan.wordpress.com/2010/09...s-y-leer-texto/

pantallazo-13

Saludos

Julio Sanchez
 




===================
Blog personal
Web: SoloGambas seleccion de articulos dedicados a Gambas
Visita el Curso de Gambas3 ¡¡¡Gratuito!!!
 
jsbsan - Ver perfil del usuarioEnviar mensaje privadoVisitar sitio web del usuario 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: Aplicacion Para Convertir Numeros A Letras 
 
hola buenos días necesito una ayuda tengo un valuebox en un formulario que es la suma de una serie de valores, como hago para que cuando me muestre ese valor de esa suma en el valuebox, automáticamente me lo coloque en letras en un reporte realizado en gb.report de gambas 3.0.0 ya realice un formulario parecido al de usted pero me exigen que lo coloque automaticamente sin necesidad de usar ese formulario aparte podria ayudarme? tambien coloque un codigo en el reportlabel que debe mostrar esa información y nada espero su repuesta y de antemano gracias
 



 
Josec - Ver perfil del usuarioEnviar mensaje privado 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: Aplicacion Para Convertir Numeros A Letras 
 
Con gb.report, no he trabajado, pero muestrame tu código con lo que haces el reporte-
Seguramente tendras que poner  una etiqueta al que le darás el valor que te genere el codigo de la función  del numero a letras.

Nota:
El formulario lo puedes convertir en una función al que le des un numero, y te devuelva la cadena de texto del numero convertido en letras.
 




===================
Blog personal
Web: SoloGambas seleccion de articulos dedicados a Gambas
Visita el Curso de Gambas3 ¡¡¡Gratuito!!!
 
jsbsan - Ver perfil del usuarioEnviar mensaje privadoVisitar sitio web del usuario 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: Aplicacion Para Convertir Numeros A Letras 
 
ok gracias por tu aporte tratare de hacerlo asi a ver si me da
 



 
Josec - Ver perfil del usuarioEnviar mensaje privado 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: Aplicacion Para Convertir Numeros A Letras 
 
Mira, aqui tienes una clase que cree para no usar el programa (seguro que te vale)
Ejemplo de uso:


 Dim num As New NumeroAletra
num.centimo = "centimo" '
  num.moneda = "euro" 'moneda, el programa se encarga de ponerlo en plural si hace falta
  num.valor = 123234.23 'valor que quiero convertir
   num.convertiraletra() 'procedimiento que crea el texto
  Print num.enletra 'escribe en la consola el texto.
 


Este es el código de la clase NumeroAletra

' gambas class file

Export

Property valor As Float
Private hvalor As Float
Property enletra As String
Private henletra As String
Property moneda As String
Private hmoneda As String
Property centimo As String
Private hcentimo As String

Public Const _Properties As String = "valor,moneda,centimo,enletra"

Private Function valor_Read() As Float
Return hvalor
End

Private Sub valor_Write(Value As Float)
hvalor = value
End


Private Function enletra_Read() As String
  Return henletra
End

Private Sub enletra_Write(Value As String)
 henletra = Value '
End

Private Function moneda_Read() As String
Return hmoneda
End

Private Sub moneda_Write(Value As String)
hmoneda = Value
End

Private Function centimo_Read() As String
Return hcentimo
End

Private Sub centimo_Write(Value As String)
hcentimo = Value
End


Public Sub convertiraletra()
henletra = ConvierteNumero_a_letras(hvalor, hmoneda, hcentimo)
End


Private Function ConvierteNumero_a_letras(valor As Float, moneda As String, centimo As String) As String
Dim i As Float
Dim r As Float
Dim hastacoma As String
Dim texto As String
Dim monedaPlural As String
Dim mCentPlural As String
Dim mcent As String
moneda = Upper$(moneda)
mcent = Upper$(centimo)
monedaPlural = palabraPlural(moneda)
mCentPlural = palabraPlural(mCent)
i = Int(valor)
r = (valor - i) * 100
If i = 0 Then
    If r = 1 Then
      Return Num2Text(r) & " " & mCent & " "
    Endif
    If r > 1 Then
      Return Num2Text(r) & " " & mCentPlural & " "
    Endif
  Else
If r = 0 Then
  If i = 1 Then
  Return Num2Text(i) & " " & moneda
  Endif
  If i > 1 Then
  Return Num2Text(i) & " " & monedaPlural
  Endif
  Else
  r = Round(r, -1) 'para tener números exactos redondeo los decimales en caso que el valor venga con más de 2 decimales.
  r = Int(r)
  If i = 1 Then
    If r = 1 Then Return Num2Text(i) & " " & moneda & " CON " & Num2Text(r) & " " & mCent
    If r > 1 Then Return Num2Text(i) & " " & moneda & " CON " & Num2Text(r) & " " & mCentPlural
  Else
  If r = 1 Then Return Num2Text(i) & " " & monedaPlural & " CON " & Num2Text(r) & " " & mCent
  If r > 1 Then Return Num2Text(i) & " " & monedaPlural & " CON " & Num2Text(r) & " " & mCentPlural
  Endif
  Endif
Endif
End
'--------------------------------
'poner plurales en castellano
'--------------------------------
Private Function palabraPlural(texto As String) As String
Dim vocal As String
Dim ultimaLetra As String
If texto = "" Then Return " "
vocal = "AEIOU"
ultimaLetra = Right(texto, 1)
If (InStr(vocal, ultimaLetra)) Then
Return texto & "S"
Else
Return texto & "ES"
Endif
End
'--------------------------------
'escribir el numero
'--------------------------------
Private Function Num2Text(value As Long) As String
Dim texto As String
If value = 0 Then Return "CERO"
If value = 1 Then Return "UN"
If value = 2 Then Return "DOS"
If value = 3 Then Return "TRES"
If value = 4 Then Return "CUATRO"
If value = 5 Then Return "CINCO"
If value = 6 Then Return "SEIS"
If value = 7 Then Return "SIETE"
If value = 8 Then Return "OCHO"
If value = 9 Then Return "NUEVE"
If value = 10 Then Return "DIEZ"
If value = 11 Then Return "ONCE"
If value = 12 Then Return "DOCE"
If value = 13 Then Return "TRECE"
If value = 14 Then Return "CATORCE"
If value = 15 Then Return "QUINCE"
If value >= 16 And value <20>= 21 And value <= 29 Then
texto = "VEINTI" & Num2Text(value - 20)
Return texto
Endif
If value = 30 Then Return "TREINTA"
If value = 40 Then Return "CUARENTA"
If value = 50 Then Return "CINCUENTA"
If value = 60 Then Return "SESENTA"
If value = 70 Then Return "SETENTA"
If value = 80 Then Return "OCHENTA"
If value = 90 Then Return "NOVENTA"
If value < 100 Then
texto = Num2Text(Int(value / 10) * 10) & " Y " & Num2Text(value Mod 10)
Return texto
Endif
If value = 100 Then Return "CIEN"
If value < 200 Then
texto = "CIENTO " & Num2Text(value - 100)
Return texto
Endif

If value = 200 Or value = 300 Or value = 400 Or value = 600 Or value = 800 Then
texto = Num2Text(Int(value / 100)) & "CIENTOS"
Return texto
Endif

If value = 500 Then Return "QUINIENTOS"
If value = 700 Then Return "SETECIENTOS"
If value = 900 Then Return "NOVECIENTOS"

If value < 1000 Then
texto = Num2Text(Int(value / 100) * 100) & " " & Num2Text(value Mod 100)
Return texto
Endif

If value = 1000 Then
Return "MIL"
Endif

If value < 2000 Then
Texto = "MIL " & Num2Text(value Mod 1000)
Return texto
Endif

If value < 1000000 Then
texto = Num2Text(Int(value / 1000)) & " MIL"
If (value Mod 1000) Then texto = texto & " " & Num2Text(value Mod 1000)
Return texto
Endif

If value = 1000000 Then texto = "UN MILLON"

If value < 2000000 Then
Texto = "UN MILLON " & Num2Text(value Mod 1000000)
Return texto
Endif

If value <1000000000000>= 2000000000000 Then
Texto = "numero demasiado grande"
Return texto
Endif

End Function
 

 




===================
Blog personal
Web: SoloGambas seleccion de articulos dedicados a Gambas
Visita el Curso de Gambas3 ¡¡¡Gratuito!!!
 
última edición por jsbsan el Lunes, 23 Enero 2012, 20:55; editado 2 veces 
jsbsan - Ver perfil del usuarioEnviar mensaje privadoVisitar sitio web del usuario 
Volver arribaPágina inferior
Mostrar mensajes anteriores:    
 
OcultarTemas parecidos
Tema Autor Foro Respuestas último mensaje
No hay nuevos mensajes Consejo Para Aplicacion destroyer General 9 Sabado, 16 Octobre 2010, 06:51 Ver último mensaje
destroyer
No hay nuevos mensajes Validacion De Letras Y Numeros ANDRYS General 3 Martes, 14 Diciembre 2010, 20:31 Ver último mensaje
razaAztk
No hay nuevos mensajes Validar Letras Y Numeros jousseph Controles/Librerías/Componentes 2 Sabado, 09 Julio 2011, 09:02 Ver último mensaje
ahtonio
No hay nuevos mensajes Reto 11(v3ctor) Función Que Devuelve Nume... v3ctor Retos de programación 9 Jueves, 15 Diciembre 2016, 22:42 Ver último mensaje
v3ctor
 

Publicar nuevo tema  Responder al tema  Página 1 de 1
 

Usuarios navegando en este tema: 0 registrados, 0 ocultos y 1 invitado
Usuarios registrados conectados: Ninguno


 
Lista de permisos
No puede crear mensajes
No puede responder temas
No puede editar sus mensajes
No puede borrar sus mensajes
No puede votar en encuestas
No puede adjuntar archivos
Puede descargar archivos
No puede publicar eventos en el calendario



  

 

cron