Attribute VB_Name = "Pesos" Option Compare Database Option Explicit Public Function convertir(ByVal AmountPassed As Currency) As String '** Convert a number to words for filling in the Amount of a check '** Example: NumWord(120.45) returns ONE HUNDRED TWENTY AND 45/100 '** Can handle numbers from 0 to $999,999,999.99 '** First working version, not yet fully tuned for speed or brevity. '** The array below, and other variables, are dimensioned '** in the Declarations section. Dim msg As String, _ EngNum(90) As String, _ StringNum As String, _ English As String, _ LoopCount As Byte, _ StartVal As Byte, _ strCentimos As String, _ Chunk As String, _ strCientos As String, _ strDecenas As String, _ strUnidades As String, _ TensDone As Boolean '** Fill EngNum array, if it's not filled already) If Not EngNum(1) = "Un" Then EngNum(0) = "" EngNum(1) = "Un" EngNum(2) = "Dos" EngNum(3) = "Tres" EngNum(4) = "Cuatro" EngNum(5) = "Cinco" EngNum(6) = "Seis" EngNum(7) = "Siete" EngNum(8) = "Ocho" EngNum(9) = "Nueve" EngNum(10) = "Diez" EngNum(11) = "Once" EngNum(12) = "Doce" EngNum(13) = "Trece" EngNum(14) = "Catorce" EngNum(15) = "Quince" EngNum(16) = "Dieciseis" EngNum(17) = "Diecisiete" EngNum(18) = "Dieciocho" EngNum(19) = "Diecinueve" EngNum(20) = "Veinte" EngNum(30) = "Treinta" EngNum(40) = "Cuarenta" EngNum(50) = "Cincuenta" EngNum(60) = "Sesenta" EngNum(70) = "Setenta" EngNum(80) = "Ochenta" EngNum(90) = "Noventa" End If '** Convert incoming Currency value to a string for parsing. StringNum = Format$(AmountPassed, "000000000.00") '** Initialize other variables English = "" LoopCount = 1 StartVal = 1 strCentimos = Mid$(StringNum, 11, 2) '** Just in case the check is for less than a buck... If AmountPassed < 1 Then English = "Cero" End If '** Now do each 3-digit section of number. For LoopCount = 1 To 3 Chunk = Mid$(StringNum, StartVal, 3) strCientos = Val(Mid$(Chunk, 1, 1)) strDecenas = Val(Mid$(Chunk, 2, 2)) strUnidades = Val(Mid$(Chunk, 3, 1)) '** Do the hundreds portion of 3-digit number If Val(Chunk) = 100 Then English = Trim(English & " Cien ") End If If Val(Chunk) > 100 And (Chunk) < 200 Then English = Trim(English & " Ciento ") End If If Val(Chunk) > 199 And (Chunk) < 300 Then English = Trim(English & " Doscientos ") End If If Val(Chunk) > 299 And (Chunk) < 400 Then English = Trim(English & " Trescientos ") End If If Val(Chunk) > 399 And (Chunk) < 500 Then English = Trim(English & EngNum(strCientos)) & " Cientos " End If If Val(Chunk) > 499 And (Chunk) < 600 Then English = Trim(English & " Quinientos") End If If Val(Chunk) > 599 And (Chunk) < 700 Then English = Trim(English & " Seiscientos ") End If If Val(Chunk) > 699 And (Chunk) < 800 Then English = Trim(English & " Setecientos") End If If Val(Chunk) > 799 And (Chunk) < 900 Then English = Trim(English & " Ochocientos ") End If If Val(Chunk) > 899 And (Chunk) < 1000 Then English = Trim(English & " Novecientos ") End If '** Do the tens & ones portion of 3-digit number TensDone = False '** Is it less than 10? If strDecenas < 10 Then English = Trim(English) & " " & EngNum(strUnidades) TensDone = True End If '** Is it a teen? If (strDecenas >= 11 And strDecenas <= 19) Then English = English & " " & EngNum(strDecenas) TensDone = True End If '** Is it Evenly Divisible by 10? If (strDecenas / 10#) = Int(strDecenas / 10#) Then English = English & " " & EngNum(strDecenas) TensDone = True End If '** Or is it none of the above? If Not TensDone Then English = English & " " & EngNum((Int(strDecenas / 10)) * 10) English = Trim(English) & " y " & EngNum(strUnidades) End If '** Add the word "million" if necessary. If LoopCount = 1 And Val(Chunk) = 1 Then English = Trim(English) + " Millon " End If If LoopCount = 1 And Val(Chunk) > 1 Then English = Trim(English) + " Millones " End If '** Add the word "thousand" if necessary. If LoopCount = 2 And Val(Chunk) > 0 Then English = Trim(English) + " Mil" End If '** Do pass through second three digits StartVal = StartVal + 3 Next LoopCount '** Done: Return english with pennies tacked on. convertir = Trim(English) & " pesos con " & strCentimos & "/100 M.N." Exit Function NumWord_Err: msg = "Error es " & Error$ & Chr(13) & Chr(10) & "En Convertir()" & Chr(13) & Chr(10) MsgBox msg, 16, "Application Error" Exit Function End Function