Visual Basic - De Números a Letras eh Impresiones

Life is soft - evento anual de software empresarial
 
Vista:
Imágen de perfil de Luis

De Números a Letras eh Impresiones

Publicado por Luis (4 intervenciones) el 12/12/2014 01:46:45
Buenas Tardes/Noches a todos los que se encuentran aqui.

Bueno mi motivo es el Siguiente tengo un deber de mi clase y quiero que nos ayuden con lo siguiente:

-Realizar un cheque con la funciòn de poder ingresar una cantidad y tansformarla a letras
-Imprimir Dicho cheque
Seria de mucha ayuda y de antemano les adelando mis Agradecimientos!

*/ Dejo un Ejemplo esta echo en Paint


EJEMPLO_CHEQUE
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Luis

De Números a Letras eh Impresiones

Publicado por Luis (4 intervenciones) el 12/12/2014 13:37:44
Hola amigo bueno si pero no es para transformar en excel lo que quiero, es en el mismo visual con 2 TextBox Gracias.!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 6
Ha disminuido su posición en 9 puestos en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

De Números a Letras eh Impresiones

Publicado por Megamind (120 intervenciones) el 12/12/2014 13:54:21
O mucho me equivoco, o eso hace lo que tu pides
creo que si llamas a la funcion
Text1.text=ENLETRAS(1457)

Pienso que el resultado en el text1 seria
MIL CUATROCIENTOS CINCUENTA Y SIETE
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 6
Ha disminuido su posición en 9 puestos en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

De Números a Letras eh Impresiones

Publicado por Megamind (120 intervenciones) el 12/12/2014 14:15:39
Lo e probado y funciona
Pego el texto aquí

Solo tienes que añadir al formulario un Text1 y un Command1
Y pegar el texto para probarlo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Function ENLETRAS(x)
parte1 = Int(x / 1000000)
parte2 = Int((x - parte1 * 1000000) / 1000)
parte3 = x - parte1 * 1000000 - parte2 * 1000
If parte1 = 0 Then millon = ""
If parte1 = 1 Then millon = "UN MILLÓN "
If parte1 > 1 Then
millon = NOMBRE(parte1) + " MILLONES "
If (parte1 - 100 * Int(parte1 / 100) > 11) And ((parte1 - 10 * Int(parte1 / 10)) = 1) Then millon = Mid(NOMBRE(parte1), 1, Len(NOMBRE(parte1)) - 1) + " MILLONES "
End If
If parte2 = 0 Then millar = ""
If parte2 = 1 Then millar = " MIL "
If parte2 > 1 Then
millar = NOMBRE(parte2) + " MIL "
If (parte2 - 100 * Int(parte2 / 100) > 11) And ((parte2 - 10 * Int(parte2 / 10)) = 1) Then millar = Mid(NOMBRE(parte2), 1, Len(NOMBRE(parte2)) - 1) + " MIL "
End If
ENLETRAS = millon + millar + NOMBRE(parte3)
If Int(x) = 0 Then ENLETRAS = "CERO"
End Function
Function NOMBRE(x)
uni = Array("", "UNO", "DOS", "TRES", "CUATRO", "CINCO", _
"SEIS", "SIETE", "OCHO", "NUEVE", "DIEZ", _
"ONCE", "DOCE", "TRECE", "CATORCE", "QUINCE", _
"DIECISEIS", "DIECISIETE", "DIECIOCHO", "DIECINUEVE", "VEINTE", _
"VEINTIUNO", "VEINTIDOS", "VEINTITRES", "VEINTICUATRO", "VEINTICINCO", _
"VEINTISEIS", "VEINTISIETE", "VEINTIOCHO", "VEINTINUEVE")
 
dec = Array("", "", "", "TREINTA", "CUARENTA", "CINCUENTA", _
"SESENTA", "SETENTA", "OCHENTA", "NOVENTA")
cent = Array("", "CIENTO", "DOSCIENTOS", "TRESCIENTOS", "CUATROCIENTOS", _
"QUINIENTOS", "SEISCIENTOS", "SETECIENTOS", "OCHOCIENTOS", "NOVECIENTOS")
 
 
xcent = Int(x / 100)
xdec = Int(x / 10) - 10 * xcent
xuni = x - 100 * xcent - 10 * xdec
 
If xdec > 2 Then
   NOMBRE = dec(xdec)
If xuni > 0 Then
  NOMBRE = NOMBRE + " Y " + uni(xuni)
End If
Else
NOMBRE = uni(xdec * 10 + xuni)
End If
 
If xcent > 0 Then NOMBRE = cent(xcent) + " " + NOMBRE
If x = 100 Then NOMBRE = "CIEN"
End Function
 
Private Sub Command1_Click()
Text1.Text = ENLETRAS(1547)
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Luis

De Números a Letras eh Impresiones

Publicado por Luis (4 intervenciones) el 13/12/2014 01:52:52
Muchas Gracias @Megamind pero una consulta estabamos probando el codigo en la clase y digamos si ingreso 300.50 sale Trescientos uno.

Tambien podria contactarme contigo por otro medio para hacer otras consulta seria poble de Antemano Muchas Gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 6
Ha disminuido su posición en 9 puestos en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

De Números a Letras eh Impresiones

Publicado por Megamind (120 intervenciones) el 13/12/2014 06:43:12
Pues parece que si tiene ese fallito, sin embargo, quizás aya una solución.
Y es descomponiendo el valor para hacer dos llamadas a la función
Ejemplo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Private Sub Command1_Click()
On Error Resume Next
Dim Cuenta As Integer
Dim t() As String
 
t = Split(Text2, ",") ' El text2 contiene la cantidad para el cheque en números
Valor = UBound(t)
 
For Cuenta = 0 To Valor
   If LTrim(RTrim(t(Cuenta))) <> "" Then
    nEntero = t(0)
    nDecimal = t(1)
   End If
Next
 
'Si el decimal solo tiene un caracter
'Suponemos que sera 10,20,30 etc. centimos
 
If Len(nDecimal) = 1 Then
   nDecimal = nDecimal & "0"
  End If
 
If Cuenta > 1 Then 'Si tiene decimales
 Text1 = ENLETRAS(nEntero) & " CON " & ENLETRAS(nDecimal) & " CENTIMOS"
Else ' O si no los tiene
 Text1 = ENLETRAS(nEntero)
End If
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar