Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Programanconvertirnnumerosnennletrasnn1nnn1n 665f69eedb4e2bc
Programanconvertirnnumerosnennletrasnn1nnn1n 665f69eedb4e2bc
Les envío un programa que les puede servir para programar una macro, la
idea es la hoja de la factura poder implementarla, recuerden que debemos
de iniciar a grabar la macro antes de los siguientes pasos:
'**********************************************************************
'** **'
'** CONVERTIR DE NUMEROS A LETRAS **'
'** **'
'** licencia: USO LIBRE **'
'** **'
'** **'
'** **'
'**********************************************************************
Public Function CLetras(ByVal numero As Double, Optional fmtoUnidad As
Integer = 0, Optional Unidades As String = "Kilos", Optional Unidad As
String = "Kilo", Optional Genero As String = "M") As String
Dim strUnidad(0 To 5) As String
Dim strUnidades(0 To 5) As String
Dim strCifras(0 To 4) As String
Dim NumeroCifras As Byte
Dim NumeroTercios As Byte
Dim strNumero As String
Dim strTMP As String
Dim dblNumeroEntero As Double
Dim intNumeroTmp As Integer
Dim intCentavos As Integer
Dim J As Integer
Dim intNumTmp As Integer
CLetras = strTMP
End Function
intNumeroEntero = Int(numero)
Centenas = Int(numero / 100)
If Genero = "M" Then
strCentenas(1) = "ciento": strCentenas(2) = "doscientos":
strCentenas(3) = "trecientos": strCentenas(4) = "cuatrocientos":
strCentenas(5) = "quinientos": strCentenas(6) = "seiscientos":
strCentenas(7) = "setecientos": strCentenas(8) = "ochocientos":
strCentenas(9) = "novecientos"
Else
strCentenas(1) = "ciento": strCentenas(2) = "doscientas":
strCentenas(3) = "trecientas": strCentenas(4) = "cuatrocientas":
strCentenas(5) = "quinientas": strCentenas(6) = "seiscientas":
strCentenas(7) = "setecientas": strCentenas(8) = "ochocientas":
strCentenas(9) = "novecientas"
End If
Select Case numero
Case 0 To 99
strTMP = CLetrasS2(intNumeroEntero, Genero)
Case 100
strTMP = "cien"
Case 200, 300, 400, 500, 600, 700, 800, 900
strTMP = strCentenas(Centenas)
Case Else
strTMP = strCentenas(Centenas) & " " & CLetrasS2(Int(numero -
(Centenas * 100)), Genero)
End Select
CLetrasS1 = strTMP
End Function
OrdenInverso = Len(CStr(numero))
'Borra la matriz
For CadaCifra = 1 To 12: NombreCifra(CadaCifra) = "0": Next CadaCifra