Convertir número a letra
Publicado por Sergio (16 intervenciones) el 18/04/2015 19:06:35
Hola. Existe alguna función que convierta un número a letras, por ej: 1.000 y que figura un mil. Gracias.
Valora esta pregunta


0
Public Function Num2Text(ByVal value As Double) As String
Select Case value
Case 0: Num2Text = "CERO"
Case 1: Num2Text = "UNO"
Case 2: Num2Text = "DOS"
Case 3: Num2Text = "TRES"
Case 4: Num2Text = "CUATRO"
Case 5: Num2Text = "CINCO"
Case 6: Num2Text = "SEIS"
Case 7: Num2Text = "SIETE"
Case 8: Num2Text = "OCHO"
Case 9: Num2Text = "NUEVE"
Case 10: Num2Text = "DIEZ"
Case 11: Num2Text = "ONCE"
Case 12: Num2Text = "DOCE"
Case 13: Num2Text = "TRECE"
Case 14: Num2Text = "CATORCE"
Case 15: Num2Text = "QUINCE"
Case Is < 20: Num2Text = "DIECI" & Num2Text(value - 10)
Case 20: Num2Text = "VEINTE"
Case Is < 30: Num2Text = "VEINTI" & Num2Text(value - 20)
Case 30: Num2Text = "TREINTA"
Case 40: Num2Text = "CUARENTA"
Case 50: Num2Text = "CINCUENTA"
Case 60: Num2Text = "SESENTA"
Case 70: Num2Text = "SETENTA"
Case 80: Num2Text = "OCHENTA"
Case 90: Num2Text = "NOVENTA"
Case Is < 100: Num2Text = Num2Text(Int(value \ 10) * 10) & " Y " & Num2Text(value Mod 10)
Case 100: Num2Text = "CIEN"
Case Is < 200: Num2Text = "CIENTO " & Num2Text(value - 100)
Case 200, 300, 400, 600, 800: Num2Text = Num2Text(Int(value \ 100)) & "CIENTOS"
Case 500: Num2Text = "QUINIENTOS"
Case 700: Num2Text = "SETECIENTOS"
Case 900: Num2Text = "NOVECIENTOS"
Case Is < 1000: Num2Text = Num2Text(Int(value \ 100) * 100) & " " & Num2Text(value Mod 100)
Case 1000: Num2Text = "MIL"
Case Is < 2000: Num2Text = "MIL " & Num2Text(value Mod 1000)
Case Is < 1000000: Num2Text = Num2Text(Int(value \ 1000)) & " MIL"
If value Mod 1000 Then Num2Text = Num2Text & " " & Num2Text(value Mod 1000)
Case 1000000: Num2Text = "UN MILLON"
Case Is < 2000000: Num2Text = "UN MILLON " & Num2Text(value Mod 1000000)
Case Is < 1000000000000#
Num2Text = Num2Text(Int(value / 1000000)) & " MILLONES "
If (value - Int(value / 1000000) * 1000000) Then Num2Text = Trim(Num2Text) & " " & Num2Text(value - Int(value / 1000000) * 1000000)
Case 1000000000000#: Num2Text = "UN BILLON"
Case Is < 2000000000000#: Num2Text = "UN BILLON " & Num2Text(value - Int(value / 1000000000000#) * 1000000000000#)
Case Else
Num2Text = Num2Text(Int(value / 1000000000000#)) & " BILLONES"
If (value - Int(value / 1000000000000#) * 1000000000000#) Then Num2Text = Num2Text & " " & Num2Text(value - Int(value / 1000000000000#) * 1000000000000#)
End Select
End Function
Function PesosMN(tyCantidad As Currency) As String
Dim lyCantidad As Currency, lyCentavos As Currency, lnDigito As Byte, lnPrimerDigito As Byte, lnSegundoDigito As Byte, lnTercerDigito As Byte, lcBloque As String, lnNumeroBloques As Byte, lnBloqueCero
Dim laUnidades As Variant, laDecenas As Variant, laCentenas As Variant, i As Variant 'Si esta como Option Explicit
tyCantidad = Round(tyCantidad, 2)
lyCantidad = Int(tyCantidad)
lyCentavos = (tyCantidad - lyCantidad) * 100
laUnidades = Array("Un", "Dos", "Tres", "Cuatro", "Cinco", "Seis", "Siete", "Ocho", "Nueve", "Diez", "Once", "Doce", "Trece", "Catorce", "Quince", "Dieciseís", "Diecisiete", "Dieciocho", "Diecinueve", "Veinte", "Veintiún", "Veintidós", "Veintitrés", "Veinticuatro", "Veinticinco", "Veintiseis", "Veintisiete", "Veintiocho", "Veintinueve")
laDecenas = Array("Diez", "Veinte", "Treinta", "Cuarenta", "Cincuenta", "Sesenta", "Setenta", "Ochenta", "Noventa")
laCentenas = Array("Ciento", "Doscientos", "Trescientos", "Cuatrocientos", "Quinientos", "Seiscientos", "Setecientos", "Ochocientos", "Novecientos")
lnNumeroBloques = 1
Do
lnPrimerDigito = 0
lnSegundoDigito = 0
lnTercerDigito = 0
lcBloque = ""
lnBloqueCero = 0
For i = 1 To 3
lnDigito = lyCantidad Mod 10
If lnDigito <> 0 Then
Select Case i
Case 1
lcBloque = " " & laUnidades(lnDigito - 1)
lnPrimerDigito = lnDigito
Case 2
If lnDigito <= 2 Then
lcBloque = " " & laUnidades((lnDigito * 10) + lnPrimerDigito - 1)
Else
lcBloque = " " & laDecenas(lnDigito - 1) & IIf(lnPrimerDigito <> 0, " y", Null) & lcBloque
End If
lnSegundoDigito = lnDigito
Case 3
lcBloque = " " & IIf(lnDigito = 1 And lnPrimerDigito = 0 And lnSegundoDigito = 0, "CIEN", laCentenas(lnDigito - 1)) & lcBloque
lnTercerDigito = lnDigito
End Select
Else
lnBloqueCero = lnBloqueCero + 1
End If
lyCantidad = Int(lyCantidad / 10)
If lyCantidad = 0 Then
Exit For
End If
Next i
Select Case lnNumeroBloques
Case 1
PesosMN = lcBloque
Case 2
PesosMN = lcBloque & IIf(lnBloqueCero = 3, Null, " mil") & PesosMN
Case 3
PesosMN = lcBloque & IIf(lnPrimerDigito = 1 And lnSegundoDigito = 0 And lnTercerDigito = 0, " millón", " millones") & PesosMN
End Select
lnNumeroBloques = lnNumeroBloques + 1
Loop Until lyCantidad = 0
PesosMN = " " & PesosMN & IIf(tyCantidad > 1, " pesos ", " peso ") & Format(Str(lyCentavos), "00") & "/100 M.N."
End Function
PesosMN = " " & PesosMN & IIf(tyCantidad > 1, " pesos ", " peso ") & Format(Str(lyCentavos), "00") & "/100 M.N."
PesosMN = " " & PesosMN & IIf(tyCantidad > 1, " pesos ", " peso ") & "con " & IIf(lyCentavos = 0, " cero ", laDecenas(Left(lyCentavos, 1) - 1) & IIf(lnPrimerDigito <> 0, " y ", Null) & laUnidades(Right(lyCentavos, 1) - 1)) & " Centavos"
Option Compare Database
Option Explicit
Function VECentenas(VEValor As Currency) As String
Dim Cen(1 To 9) As String
Dim Dec(1 To 10) As String
Dim Uni(1 To 19) As String
Dim VEExiste As Boolean
Dim VEExtenso As String
Dim VEValor2 As Currency
Cen(1) = "Ciento"
Cen(2) = "Doscientos"
Cen(3) = "Trescientos"
Cen(4) = "Cuatrocientos"
Cen(5) = "Quinientos"
Cen(6) = "Seiscientos"
Cen(7) = "Setecientos"
Cen(8) = "Ochocientos"
Cen(9) = "Novecientos"
Dec(1) = "Diez"
Dec(2) = "Veinte"
Dec(3) = "Treinta"
Dec(4) = "Cuarenta"
Dec(5) = "Cincuenta"
Dec(6) = "Sesenta"
Dec(7) = "Setenta"
Dec(8) = "Ochenta"
Dec(9) = "Noventa"
Uni(1) = "Uno"
Uni(2) = "Dos"
Uni(3) = "Tres"
Uni(4) = "Cuatro"
Uni(5) = "Cinco"
Uni(6) = "Seis"
Uni(7) = "Siete"
Uni(8) = "Ocho"
Uni(9) = "Nueve"
Uni(10) = "Diez"
Uni(11) = "Once"
Uni(12) = "Doce"
Uni(13) = "Trece"
Uni(14) = "Catorce"
Uni(15) = "Quince"
Uni(16) = "Dieciseis"
Uni(17) = "Diecisiete"
Uni(18) = "Dieciocho"
Uni(19) = "Diecinueve"
VEExiste = False
VEExtenso = ""
If VEValor > 100 Then
VEValor2 = Int(VEValor / 100)
VEValor = VEValor - VEValor2 * 100
VEExtenso = Cen(VEValor2)
VEExiste = True
End If
If VEValor = 100 Then
VEExtenso = "Cien "
VEExiste = False
End If
If VEValor > 19 Then
VEValor2 = Int(VEValor / 10)
VEValor = VEValor - VEValor2 * 10
If VEExiste Then VEExtenso = VEExtenso & " "
VEExtenso = VEExtenso & Dec(VEValor2)
VEExiste = True
End If
If VEValor < 20 And VEValor >= 0 Then
If VEExiste And VEValor < 0 Then VEExtenso = VEExtenso & ""
If VEValor > 0 And VEValor Then VEExtenso = VEExtenso & " y " & Uni(VEValor)
End If
VECentenas = VEExtenso
End Function
Public Function ValoresExtenso(Valor As Currency, NomMoneda As String, CantDecimales As Byte) As String
Dim Centavo As Currency
Dim Millon As Currency
Dim Mil As Currency
Dim Unidades As Currency
Dim Existe As Boolean
Dim Extenso As String
Dim CD(0 To 6) As Long
CD(0) = 0
CD(1) = 10
CD(2) = 100
CD(3) = 1000
CD(4) = 10000
CD(5) = 100000
CD(6) = 1000000
If Valor = 0 Then
ValoresExtenso = "Cero " & NomMoneda
Exit Function
End If
Valor = Abs(Valor)
'Centavo = Int((Valor - Fix(Valor)) * 100)
Centavo = (Valor - Fix(Valor)) * CD(CantDecimales)
Millon = Int(Valor / 1000000)
Valor = Valor - Millon * 1000000
Mil = Int((Valor) / 1000)
Valor = Valor - Mil * 1000
Unidades = Int(Valor)
Existe = False
If Millon > 0 Then
If Millon = 1 Then Extenso = "Un Millón " Else Extenso = VECentenas(Millon) + " Millones "
Existe = True
End If
If Mil > 0 Then
If Existe And Unidades = 0 Then Extenso = Extenso & " "
If Mil = 1 Then
Extenso = Extenso & "Un Mil "
ElseIf Mil > 1 Then
Extenso = Extenso & VECentenas(Mil) & " Mil "
End If
Existe = True
End If
If Unidades > 0 Then
If Existe And Int(Unidades / 100) = Unidades / 100 Then Extenso = Extenso & " "
Extenso = Extenso & VECentenas(Unidades) & " "
End If
If Extenso = "Un Millón " Then Extenso = Extenso & "de"
Extenso = Trim(Extenso) & " " & NomMoneda
If Centavo > 0 Then
Extenso = "** " & Extenso & " con " & VECentenas(Centavo) + " Centavos.**"
Else
Extenso = "** " & Extenso & ".**"
End If
ValoresExtenso = Extenso
End Function
Function letra(Numero)
Dim Texto
Dim Millones
Dim Miles
Dim Cientos
Dim Decimales
Dim Cadena
Dim CadMillones
Dim CadMiles
Dim CadCientos
Dim caddecimales
Texto = Round(Numero, 2)
Texto = FormatNumber(Texto, 2)
Texto = Right(Space(14) & Texto, 14)
Millones = Mid(Texto, 1, 3)
Miles = Mid(Texto, 5, 3)
Cientos = Mid(Texto, 9, 3)
Decimales = Mid(Texto, 13, 2)
CadMillones = ConvierteCifra(Millones, False)
CadMiles = ConvierteCifra(Miles, False)
CadCientos = ConvierteCifra(Cientos, True)
caddecimales = ConvierteDecimal(Decimales)
If Trim(CadMillones) > "" Then
If Trim(CadMillones) = "UN" Then......
Function letra(Numero)
Dim Texto
Dim Millones
Dim Miles
Dim Cientos
Dim Decimales
Dim Cadena
Dim CadMillones
Dim CadMiles
Dim CadCientos
Dim caddecimales
Texto = Round(Numero, 2)
Texto = FormatNumber(Texto, 2)
Texto = Right(Space(14) & Texto, 14)
Millones = Mid(Texto, 1, 3)
Miles = Mid(Texto, 5, 3)
Cientos = Mid(Texto, 9, 3)
Decimales = Mid(Texto, 13, 2)
CadMillones = ConvierteCifra(Millones, False)
CadMiles = ConvierteCifra(Miles, False)
CadCientos = ConvierteCifra(Cientos, True)
caddecimales = ConvierteDecimal(Decimales)
If Trim(CadMillones) > "" Then
If Trim(CadMillones) = "UN" Then
Cadena = CadMillones & " MILLON"
Else
Cadena = CadMillones & " MILLONES"
End If
End If
If Trim(CadMiles) > "" Then
If Trim(CadMiles) = "UN" Then
CadMiles = ""
Cadena = Cadena & "" & CadMiles & "MIL"
CadMiles = "UN"
Else
Cadena = Cadena & " " & CadMiles & " MIL"
End If
End If
If Trim(CadMiles) > "001" Then
CadMiles = "MIL"
End If
If Decimales = "00" Then
If Trim(CadMillones & CadMiles & CadCientos & caddecimales) = "UN" Then
Cadena = Cadena & "UNO "
Else
If Miles & Cientos = "000000" Then
Cadena = Cadena & " " & Trim(CadCientos)
Else
Cadena = Cadena & " " & Trim(CadCientos)
End If
letra = Trim(Cadena)
End If
Else
If Trim(CadMillones & CadMiles & CadCientos & caddecimales) = "UN" Then
Cadena = Cadena & "UNO " & "CON " & Trim(caddecimales)
Else
If Millones & Miles & Cientos & Decimales = "000000" Then
Cadena = Cadena & " " & Trim(CadCientos) & " CON " & Trim(Decimales) & "/100 SOLES"
Else
Cadena = Cadena & " " & Trim(CadCientos) & " CON " & Trim(Decimales) & "/100 SOLES"
End If
letra = Trim(Cadena)
End If
End If
End Function
Function ConvierteCifra(Texto, IsCientos As Boolean)
Dim Centena
Dim Decena
Dim Unidad
Dim txtCentena
Dim txtDecena
Dim txtUnidad
Centena = Mid(Texto, 1, 1)
Decena = Mid(Texto, 2, 1)
Unidad = Mid(Texto, 3, 1)
Select Case Centena
Case "1"
txtCentena = "CIEN"
If Decena & Unidad <> "00" Then
txtCentena = "CIENTO"
End If
Case "2"
txtCentena = "DOSCIENTOS"
Case "3"
txtCentena = "TRESCIENTOS"
Case "4"
txtCentena = "CUATROCIENTOS"
Case "5"
txtCentena = "QUINIENTOS"
Case "6"
txtCentena = "SEISCIENTOS"
Case "7"
txtCentena = "SETECIENTOS"
Case "8"
txtCentena = "OCHOCIENTOS"
Case "9"
txtCentena = "NOVECIENTOS"
End Select
Select Case Decena
Case "1"
txtDecena = "DIEZ"
Select Case Unidad
Case "1"
txtDecena = "ONCE"
Case "2"
txtDecena = "DOCE"
Case "3"
txtDecena = "TRECE"
Case "4"
txtDecena = "CATORCE"
Case "5"
txtDecena = "QUINCE"
Case "6"
txtDecena = "DIECISEIS"
Case "7"
txtDecena = "DIECISIETE"
Case "8"
txtDecena = "DIECIOCHO"
Case "9"
txtDecena = "DIECINUEVE"
End Select
Case "2"
txtDecena = "VEINTE"
If Unidad <> "0" Then
txtDecena = "VEINTI"
End If
Case "3"
txtDecena = "TREINTA"
If Unidad <> "0" Then
txtDecena = "TREINTA Y "
End If
Case "4"
txtDecena = "CUARENTA"
If Unidad <> "0" Then
txtDecena = "CUARENTA Y "
End If
Case "5"
txtDecena = "CINCUENTA"
If Unidad <> "0" Then
txtDecena = "CINCUENTA Y "
End If
Case "6"
txtDecena = "SESENTA"
If Unidad <> "0" Then
txtDecena = "SESENTA Y "
End If
Case "7"
txtDecena = "SETENTA"
If Unidad <> "0" Then
txtDecena = "SETENTA Y "
End If
Case "8"
txtDecena = "OCHENTA"
If Unidad <> "0" Then
txtDecena = "OCHENTA Y "
End If
Case "9"
txtDecena = "NOVENTA"
If Unidad <> "0" Then
txtDecena = "NOVENTA Y "
End If
End Select
If Decena <> "1" Then
Select Case Unidad
Case "1"
If IsCientos = False Then
txtUnidad = "UN"
Else
txtUnidad = "UNO"
End If
Case "2"
txtUnidad = "DOS"
Case "3"
txtUnidad = "TRES"
Case "4"
txtUnidad = "CUATRO"
Case "5"
txtUnidad = "CINCO"
Case "6"
txtUnidad = "SEIS"
Case "7"
txtUnidad = "SIETE"
Case "8"
txtUnidad = "OCHO"
Case "9"
txtUnidad = "NUEVE"
End Select
End If
ConvierteCifra = txtCentena & " " & txtDecena & txtUnidad
End Function
Function ConvierteDecimal(Texto)
Dim Decenadecimal
Dim Unidaddecimal
Dim txtDecenadecimal
Dim txtUnidaddecimal
Decenadecimal = Mid(Texto, 1, 1)
Unidaddecimal = Mid(Texto, 2, 1)
Select Case Decenadecimal
Case "1"
txtDecenadecimal = "DIEZ"
Select Case Unidaddecimal
Case "1"
txtDecenadecimal = "ONCE"
Case "2"
txtDecenadecimal = "DOCE"
Case "3"
txtDecenadecimal = "TRECE"
Case "4"
txtDecenadecimal = "CATORCE"
Case "5"
txtDecenadecimal = "QUINCE"
Case "6"
txtDecenadecimal = "DIECISEIS"
Case "7"
txtDecenadecimal = "DIECISIETE"
Case "8"
txtDecenadecimal = "DIECIOCHO"
Case "9"
txtDecenadecimal = "DIECINUEVE"
End Select
Case "2"
txtDecenadecimal = "VEINTE"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "VEINTI"
End If
Case "3"
txtDecenadecimal = "TREINTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "TREINTA Y "
End If
Case "4"
txtDecenadecimal = "CUARENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "CUARENTA Y "
End If
Case "5"
txtDecenadecimal = "CINCUENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "CINCUENTA Y "
End If
Case "6"
txtDecenadecimal = "SESENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "SESENTA Y "
End If
Case "7"
txtDecenadecimal = "SETENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "SETENTA Y "
End If
Case "8"
txtDecenadecimal = "OCHENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "OCHENTA Y "
End If
Case "9"
txtDecenadecimal = "NOVENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "NOVENTA Y "
End If
End Select
If Decenadecimal <> "1" Then
Select Case Unidaddecimal
Case "1"
txtUnidaddecimal = "UNO"
Case "2"
txtUnidaddecimal = "DOS"
Case "3"
txtUnidaddecimal = "TRES"
Case "4"
txtUnidaddecimal = "CUATRO"
Case "5"
txtUnidaddecimal = "CINCO"
Case "6"
txtUnidaddecimal = "SEIS"
Case "7"
txtUnidaddecimal = "SIETE"
Case "8"
txtUnidaddecimal = "OCHO"
Case "9"
txtUnidaddecimal = "NUEVE"
End Select
End If
If Decenadecimal = 0 And Unidaddecimal = 0 Then
ConvierteDecimal = ""
Else
ConvierteDecimal = txtDecenadecimal & txtUnidaddecimal
End If
End Function
………...
If Decenadecimal = 0 And Unidaddecimal = 0 Then
ConvierteDecimal = ""
Else
ConvierteDecimal = txtDecenadecimal & txtUnidaddecimal
End If
…………...
Option Compare Database
Function letra(ByVal Numero As Double)
Dim Texto
Dim Millones
Dim Miles
Dim Cientos
Dim Decimales
Dim Cadena
Dim CadMillones
Dim CadMiles
Dim CadCientos
Dim caddecimales
Texto = Round(Numero, 2)
Texto = FormatNumber(Texto, 2, vbTrue, vbFalse, vbTrue)
Texto = Right(Space(14) & Texto, 14)
Millones = Mid(Texto, 1, 3)
Miles = Mid(Texto, 5, 3)
Cientos = Mid(Texto, 9, 3)
Decimales = Mid(Texto, 13, 2)
CadMillones = ConvierteCifra(Millones, False)
CadMiles = ConvierteCifra(Miles, False)
CadCientos = ConvierteCifra(Cientos, True)
caddecimales = ConvierteDecimal(Decimales)
If Trim(CadMillones) > "" Then
If Trim(CadMillones) = "UN" Then
CadMillones = "UN"
Cadena = Cadena & CadMillones & " MILLON"
Else
Cadena = CadMillones & " MILLONES"
End If
End If
If Trim(CadMiles) > "" Then
If Trim(CadMiles) = "UN" Then
CadMiles = ""
Cadena = Cadena & "" & CadMiles & "MIL"
CadMiles = "UN"
Else
Cadena = Cadena & " " & CadMiles & " MIL"
End If
End If
If Trim(CadMiles) > "001" Then
CadMiles = "MIL"
End If
If Decimales = "00" Then
If Trim(CadMillones & CadMiles & CadCientos & caddecimales) = "UN" Then
Cadena = Cadena '& "UNO "
Else
If Miles & Cientos = "000000" Then
Cadena = Cadena & " " & Trim(CadCientos)
Else
Cadena = Cadena & " " & Trim(CadCientos)
End If
letra = Trim(Cadena)
End If
Else
If Trim(CadMillones & CadMiles & CadCientos & caddecimales) = "UN" Then
Cadena = Cadena & "UNO " & "CON " & Trim(caddecimales)
Else
If Millones & Miles & Cientos & Decimales = "000000" Then
Cadena = StrConv(Cadena & " " & Trim(CadCientos) & " CON " & ConvierteDecimal(Decimales) & " CÉNTIMOS", vbLowerCase)
Else
Cadena = Cadena & " " & Trim(CadCientos) & " CON " & ConvierteDecimal(Decimales) & " CÉNTIMOS"
End If
letra = Trim(Cadena)
End If
letra = Trim(Cadena)
End If
letra = Trim(Cadena)
Debug.Print Cadena
End Function
Function ConvierteCifra(Texto, IsCientos As Boolean)
Dim Centena
Dim Decena
Dim Unidad
Dim txtCentena
Dim txtDecena
Dim txtUnidad
Centena = Mid(Texto, 1, 1)
Decena = Mid(Texto, 2, 1)
Unidad = Mid(Texto, 3, 1)
Select Case Centena
Case "1"
txtCentena = "CIEN"
If Decena & Unidad <> "00" Then
txtCentena = "CIENTO"
End If
Case "2"
txtCentena = "DOSCIENTOS"
Case "3"
txtCentena = "TRESCIENTOS"
Case "4"
txtCentena = "CUATROCIENTOS"
Case "5"
txtCentena = "QUINIENTOS"
Case "6"
txtCentena = "SEISCIENTOS"
Case "7"
txtCentena = "SETECIENTOS"
Case "8"
txtCentena = "OCHOCIENTOS"
Case "9"
txtCentena = "NOVECIENTOS"
End Select
Select Case Decena
Case "1"
txtDecena = "DIEZ"
Select Case Unidad
Case "1"
txtDecena = "ONCE"
Case "2"
txtDecena = "DOCE"
Case "3"
txtDecena = "TRECE"
Case "4"
txtDecena = "CATORCE"
Case "5"
txtDecena = "QUINCE"
Case "6"
txtDecena = "DIECISEIS"
Case "7"
txtDecena = "DIECISIETE"
Case "8"
txtDecena = "DIECIOCHO"
Case "9"
txtDecena = "DIECINUEVE"
End Select
Case "2"
txtDecena = "VEINTE"
If Unidad <> "0" Then
txtDecena = "VEINTI"
End If
Case "3"
txtDecena = "TREINTA"
If Unidad <> "0" Then
txtDecena = "TREINTA Y "
End If
Case "4"
txtDecena = "CUARENTA"
If Unidad <> "0" Then
txtDecena = "CUARENTA Y "
End If
Case "5"
txtDecena = "CINCUENTA"
If Unidad <> "0" Then
txtDecena = "CINCUENTA Y "
End If
Case "6"
txtDecena = "SESENTA"
If Unidad <> "0" Then
txtDecena = "SESENTA Y "
End If
Case "7"
txtDecena = "SETENTA"
If Unidad <> "0" Then
txtDecena = "SETENTA Y "
End If
Case "8"
txtDecena = "OCHENTA"
If Unidad <> "0" Then
txtDecena = "OCHENTA Y "
End If
Case "9"
txtDecena = "NOVENTA"
If Unidad <> "0" Then
txtDecena = "NOVENTA Y "
End If
End Select
If Decena <> "1" Then
Select Case Unidad
Case "1"
If IsCientos = False Then
txtUnidad = "UN"
Else
txtUnidad = "UNO"
End If
Case "2"
txtUnidad = "DOS"
Case "3"
txtUnidad = "TRES"
Case "4"
txtUnidad = "CUATRO"
Case "5"
txtUnidad = "CINCO"
Case "6"
txtUnidad = "SEIS"
Case "7"
txtUnidad = "SIETE"
Case "8"
txtUnidad = "OCHO"
Case "9"
txtUnidad = "NUEVE"
End Select
End If
ConvierteCifra = txtCentena & " " & txtDecena & txtUnidad
End Function
Function ConvierteDecimal(Texto)
Dim Decenadecimal
Dim Unidaddecimal
Dim txtDecenadecimal
Dim txtUnidaddecimal
Decenadecimal = Mid(Texto, 1, 1)
Unidaddecimal = Mid(Texto, 2, 1)
Select Case Decenadecimal
Case "1"
txtDecenadecimal = "DIEZ"
Select Case Unidaddecimal
Case "1"
txtDecenadecimal = "ONCE"
Case "2"
txtDecenadecimal = "DOCE"
Case "3"
txtDecenadecimal = "TRECE"
Case "4"
txtDecenadecimal = "CATORCE"
Case "5"
txtDecenadecimal = "QUINCE"
Case "6"
txtDecenadecimal = "DIECISEIS"
Case "7"
txtDecenadecimal = "DIECISIETE"
Case "8"
txtDecenadecimal = "DIECIOCHO"
Case "9"
txtDecenadecimal = "DIECINUEVE"
End Select
Case "2"
txtDecenadecimal = "VEINTE"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "VEINTI"
End If
Case "3"
txtDecenadecimal = "TREINTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "TREINTA Y "
End If
Case "4"
txtDecenadecimal = "CUARENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "CUARENTA Y "
End If
Case "5"
txtDecenadecimal = "CINCUENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "CINCUENTA Y "
End If
Case "6"
txtDecenadecimal = "SESENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "SESENTA Y "
End If
Case "7"
txtDecenadecimal = "SETENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "SETENTA Y "
End If
Case "8"
txtDecenadecimal = "OCHENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "OCHENTA Y "
End If
Case "9"
txtDecenadecimal = "NOVENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "NOVENTA Y "
End If
End Select
If Decenadecimal <> "1" Then
Select Case Unidaddecimal
Case "1"
If Len(Texto) > 1 Then
txtUnidaddecimal = "UN"
Else
txtUnidaddecimal = "UNO"
End If
Case "2"
txtUnidaddecimal = "DOS"
Case "3"
txtUnidaddecimal = "TRES"
Case "4"
txtUnidaddecimal = "CUATRO"
Case "5"
txtUnidaddecimal = "CINCO"
Case "6"
txtUnidaddecimal = "SEIS"
Case "7"
txtUnidaddecimal = "SIETE"
Case "8"
txtUnidaddecimal = "OCHO"
Case "9"
txtUnidaddecimal = "NUEVE"
End Select
End If
If Decenadecimal = 0 And Unidaddecimal = 0 Then
ConvierteDecimal = ""
Else
ConvierteDecimal = txtDecenadecimal & txtUnidaddecimal
End If
End Function
Debug.Print "+++++ " & Trim(CadMillones & CadMiles & CadCientos & caddecimales)
If Decimales = "00" Then
If Trim(CadMillones & CadMiles & CadCientos & caddecimales) = "Un" Then
Cadena = Cadena & "Uno "
Else
If Miles & Cientos = "000000" Then
Cadena = Cadena & " " & Trim(CadCientos)
Else
Cadena = Cadena & " " & Trim(CadCientos)
End If
letra = Trim(Cadena)
End If
Else
If Trim(CadMillones & CadMiles & CadCientos & caddecimales) = "Un" Then
Cadena = Cadena & "Uno " & "Con " & Trim(caddecimales)
Else
If Millones & Miles & Cientos & Decimales = "000000" Then
Cadena = Cadena & " " & Trim(CadCientos) & " " & "Con " & Trim(Decimales) & "/100 Soles"
'Cadena = Cadena & " " & Trim(CadCientos) & " PESOS " & Trim(Decimales) & "con/100 M.N."
Else
Cadena = Cadena & " " & Trim(CadCientos) & " " & "Con " & Trim(Decimales) & "/100 Soles"
'Cadena = Cadena & " " & Trim(CadCientos) & " PESOS " & Trim(Decimales) & "/100 M.N."
End If
letra = Trim(Cadena)
End If
End If
If Trim(CadMillones & CadMiles & CadCientos & caddecimales) = "Un" Then
Cadena = Cadena & "Uno " & "Con " & Trim(caddecimales)
Else
If Millones & Miles & Cientos & Decimales = "000000" Then
Cadena = Cadena & " " & Trim(CadCientos) & " " & "Con " & Trim(Decimales) & "/100 Soles"
'Cadena = Cadena & " " & Trim(CadCientos) & " PESOS " & Trim(Decimales) & "con/100 M.N."
Else
Cadena = Cadena & " " & Trim(CadCientos) & " " & "Con " & Trim(Decimales) & "/100 Soles"
'Cadena = Cadena & " " & Trim(CadCientos) & " PESOS " & Trim(Decimales) & "/100 M.N."
End If
letra = Trim(Cadena)
End If