Conversion de cantidades a letras

otsuj1
04 de Diciembre del 2003
Otra vez molestandolos , Hola a todos tengo un pequeño problema, estoy realizando un pequeño programa donde me escriba cantidades en letras por decir si escrivo 123 (ciento veintitres pesos 00/100 mn)
Ahora no puedo ponerle a todas cantidades la palabra "PESOS" es decir escribo 1000 me escribe UN MIL sin la palabra "PESOS" de hecho baje un codigo de internet que me hace esto´pero no lo entiendo muy bien alguien podria ayudarme por favor

Este es el codigo:
Public Function NroEnLetras(ByVal curNumero As Double, Optional blnO_Final As Boolean = True) As String
'Devuelve un número expresado en letras.
'El parámetro blnO_Final se utiliza en la recursión para saber si se debe colocar
'la "O" final cuando la palabra es UN(O)
Dim dblCentavos As Double
Dim lngContDec As Long
Dim lngContCent As Long
Dim lngContMil As Long
Dim lngContMillon As Long
Dim strNumLetras As String
Dim strNumero As Variant
Dim strDecenas As Variant
Dim strCentenas As Variant
Dim blnNegativo As Boolean
Dim blnPlural As Boolean

If Int(curNumero) = 0# Then
strNumLetras = "CERO"
End If

strNumero = Array(vbNullString, "UN", "DOS", "TRES", "CUATRO", "CINCO", "SEIS", "SIETE", _
"OCHO", "NUEVE", "DIEZ", "ONCE", "DOCE", "TRECE", "CATORCE", _
"QUINCE", "DIECISEIS", "DIECISIETE", "DIECIOCHO", "DIECINUEVE", _
"VEINTE")

strDecenas = Array(vbNullString, vbNullString, "VEINTI", "TREINTA", "CUARENTA", "CINCUENTA", "SESENTA", _
"SETENTA", "OCHENTA", "NOVENTA", "CIEN")

strCentenas = Array(vbNullString, "CIENTO", "DOSCIENTOS", "TRESCIENTOS", _
"CUATROCIENTOS", "QUINIENTOS", "SEISCIENTOS", "SETECIENTOS", _
"OCHOCIENTOS", "NOVECIENTOS")

If curNumero < 0# Then
blnNegativo = True
curNumero = Abs(curNumero)
End If

If Int(curNumero) <> curNumero Then
dblCentavos = Abs(curNumero - Int(curNumero))
curNumero = Int(curNumero)
End If

Do While curNumero >= 1000000#
lngContMillon = lngContMillon + 1
curNumero = curNumero - 1000000#
Loop

Do While curNumero >= 1000#
lngContMil = lngContMil + 1
curNumero = curNumero - 1000#
Loop

Do While curNumero >= 100#
lngContCent = lngContCent + 1
curNumero = curNumero - 100#
Loop

If Not (curNumero > 10# And curNumero <= 20#) Then
Do While curNumero >= 10#
lngContDec = lngContDec + 1
curNumero = curNumero - 10#
Loop
End If

If lngContMillon > 0 Then
If lngContMillon >= 1 Then 'si el número es >1000000 usa recursividad
strNumLetras = NroEnLetras(lngContMillon, False)
If Not blnPlural Then blnPlural = (lngContMillon > 1)
lngContMillon = 0
End If
strNumLetras = Trim(strNumLetras) & strNumero(lngContMillon) & " MILLON" & _
IIf(blnPlural, "ES ", " ")
End If

If lngContMil > 0 Then
If lngContMil >= 1 Then 'si el número es >100000 usa recursividad
strNumLetras = strNumLetras & NroEnLetras(lngContMil, False)
lngContMil = 0
End If
strNumLetras = Trim(strNumLetras) & strNumero(lngContMil) & " MIL "
End If

If lngContCent > 0 Then
If lngContCent = 1 And lngContDec = 0 And curNumero = 0# Then
strNumLetras = strNumLetras & "CIEN"
Else
strNumLetras = strNumLetras & strCentenas(lngContCent) '& " PESOS"
End If
End If

If lngContDec >= 1 Then
If lngContDec = 1 Then
strNumLetras = strNumLetras & strNumero(10) ' & "PESOS"
Else
strNumLetras = strNumLetras & strDecenas(lngContDec) '& "PESOS"
End If

If lngContDec >= 3 And curNumero > 0# Then
strNumLetras = strNumLetras & " Y "
End If
Else
If curNumero >= 0# And curNumero <= 20# Then
strNumLetras = Trim(strNumLetras) & strNumero(curNumero) '& "PESOS"
If curNumero = 1# And blnO_Final Then
strNumLetras = strNumLetras & "O"
End If
If dblCentavos > 0# Then
strNumLetras = Trim(strNumLetras) & " PESOS " & Format$(CInt(dblCentavos * 100#), "00") & "/100"
End If
NroEnLetras = strNumLetras
Exit Function
End If
End If

If curNumero > 0# Then
strNumLetras = strNumLetras & strNumero(curNumero)
If curNumero = 1# And blnO_Final Then
strNumLetras = strNumLetras & "O"
End If
End If

If dblCentavos > 0# Then
strNumLetras = strNumLetras & " PESOS " + Format$(CInt(dblCentavos * 100#), "00") & "/100"
End If

NroEnLetras = IIf(blnNegativo, "(" & strNumLetras & ")", strNumLetras)
End Function

La verdad no se mucho de funciones, si alguien podria espicarme como funciona esto se lo agradeceria mucho.



KayKay
04 de Diciembre del 2003
Te paso la funcion siguiente :
Esta funcion transforma una numero de hasta con dos decimales a letras, te lo traduce en dos idiomas en castellano y en catalan, si quieres que te lo haga en castellano pon la variable "Catalan" a False. Si tu lo quieres poner a Pesos añade al final de lo que te retorna la palabra Pesos.

Public Sub Transforma(Valor As String)

Dim frase As String
Dim letra As String
Dim palabra1 As String
Dim palabra2 As String
Dim palabra3 As String
Dim palabra4 As String
Dim palabra5 As String
Dim palabra6 As String
Dim palabra7 As String
Dim palabra8 As String
Dim palabra9 As String
Dim palabra10 As String
Dim palabra11 As String

Dim i As Integer
Dim j As Integer
Dim longitud As Integer
Dim okupas As Integer
Dim cifra() As String

Dim palabra As String
Dim mas_uno, mas_dos As Integer
Dim catalan As Boolean
Dim gfemenino As Boolean
Dim decimales As String

gfemenino = False

catalan = True 'Aqui decides el idioma

frase = ""
palabra11 = ""
palabra10 = ""
palabra9 = ""
palabra8 = ""
palabra7 = ""
palabra6 = ""
palabra5 = ""
palabra4 = ""
palabra3 = ""
palabra2 = ""
palabra1 = ""

letra = CStr(Mid(CStr(Valor), 1, Len(CStr(Valor)) - 3))
decimales = Right(CStr(Valor), 2)
letra = Replace(letra, ".", "")

longitud = Len(letra)

ReDim cifra(longitud)

For i = 1 To longitud
cifra(i) = Mid(letra, i, 1)
Next i

i = 9 - longitud + 1
okupas = longitud
j = 1
Dim z As Integer
z = 0

Do While z <= 1
Do While j <= longitud
Select Case cifra(j)
Case "0"
Case "1"
Select Case i
Case 1
'nums100
mas_uno = j + 1
mas_dos = j + 2
If cifra(mas_uno) = "0" And cifra(mas_dos) = "0" Then
palabra = IIf(catalan, " CENT", " CIEN")
If (j = 4) And (okupas = 6) Then
palabra4 = " MIL"
Else
If (j = 1) And (okupas = 9) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
End If
End If
j = j + 2
i = i + 2
Else
palabra = IIf(catalan, " CENT", " CIENTO")
End If
'fnums100
palabra11 = palabra
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 2
'nums10
mas_uno = j + 1
Select Case cifra(mas_uno)
Case "0"
palabra = IIf(catalan, " DEU", " DIEZ")
j = j + 1
i = i + 1
Case "1"
palabra = IIf(catalan, " ONZE", " ONCE")
j = j + 1
i = i + 1
Case "2"
palabra = IIf(catalan, " DOTZE", " DOCE")
j = j + 1
i = i + 1
Case "3"
palabra = IIf(catalan, " TRETZE", " TRECE")
j = j + 1
i = i + 1
Case "4"
palabra = IIf(catalan, " CATORZE", " CATORCE")
j = j + 1
i = i + 1
Case "5"
palabra = IIf(catalan, " QUINZE", " QUINCE")
j = j + 1
i = i + 1
Case "6"
If catalan Then
palabra = " SETZE"
j = j + 1
i = i + 1
Else
palabra = " DIECI"
End If
Case "7"
If catalan Then
palabra = " DISSET"
j = j + 1
i = i + 1
Else
palabra = " DIECI"
End If
Case Else
palabra = IIf(catalan, " DI", " DIECI")
End Select
'fnums10
palabra10 = palabra
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 3
palabra9 = " UN"
If palabra10 = "" And palabra11 = "" Then
palabra8 = IIf(catalan, " MILIO", " MILLON")
Else
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
End If
Case 4
'nums100
mas_uno = j + 1
mas_dos = j + 2
If cifra(mas_uno) = "0" And cifra(mas_dos) = "0" Then
palabra = IIf(catalan, " CENT", " CIEN")
If (j = 4) And (okupas = 6) Then
palabra4 = " MIL"
Else
If (j = 1) And (okupas = 9) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
End If
End If
j = j + 2
i = i + 2
Else
palabra = IIf(catalan, " CENT", " CIENTO")
End If
'fnums100
palabra7 = palabra
palabra4 = " MIL"
Case 5
'nums10
mas_uno = j + 1
Select Case cifra(mas_uno)
Case "0"
palabra = IIf(catalan, " DEU", " DIEZ")
j = j + 1
i = i + 1
Case "1"
palabra = IIf(catalan, " ONZE", " ONCE")
j = j + 1
i = i + 1
Case "2"
palabra = IIf(catalan, " DOTZE", " DOCE")
j = j + 1
i = i + 1
Case "3"
palabra = IIf(catalan, " TRETZE", " TRECE")
j = j + 1
i = i + 1
Case "4"
palabra = IIf(catalan, " CATORZE", " CATORCE")
j = j + 1
i = i + 1
Case "5"
palabra = IIf(catalan, " QUINZE", " QUINCE")
j = j + 1
i = i + 1
Case "6"
If catalan Then
palabra = " SETZE"
j = j + 1
i = i + 1
Else
palabra = " DIECI"
End If
Case "7"
If catalan Then
palabra = " DISSET"
j = j + 1
i = i + 1
Else
palabra = " DIECI"
End If
Case Else
palabra = IIf(catalan, " DI", " DIECI")
End Select
'fnums10
palabra6 = palabra
palabra4 = " MIL"
Case 6
If Val(letra) > Val("1999") Then
If gfemenino Then
palabra5 = " UNA"
Else
palabra5 = " UN"
End If
palabra4 = " MIL"
Else
palabra4 = " MIL"
End If
Case 7
'nums100
mas_uno = j + 1
mas_dos = j + 2
If cifra(mas_uno) = "0" And cifra(mas_dos) = "0" Then
palabra = IIf(catalan, " CENT", " CIEN")
If (j = 4) And (okupas = 6) Then
palabra4 = " MIL"
Else
If (j = 1) And (okupas = 9) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
End If
End If
j = j + 2
i = i + 2
Else
palabra = IIf(catalan, " CENT", " CIENTO")
End If
'fnums100
palabra3 = palabra
Case 8
'nums10
mas_uno = j + 1
Select Case cifra(mas_uno)
Case "0"
palabra = IIf(catalan, " DEU", " DIEZ")
j = j + 1
i = i + 1
Case "1"
palabra = IIf(catalan, " ONZE", " ONCE")
j = j + 1
i = i + 1
Case "2"
palabra = IIf(catalan, " DOTZE", " DOCE")
j = j + 1
i = i + 1
Case "3"
palabra = IIf(catalan, " TRETZE", " TRECE")
j = j + 1
i = i + 1
Case "4"
palabra = IIf(catalan, " CATORZE", " CATORCE")
j = j + 1
i = i + 1
Case "5"
palabra = IIf(catalan, " QUINZE", " QUINCE")
j = j + 1
i = i + 1
Case "6"
If catalan Then
palabra = " SETZE"
j = j + 1
i = i + 1
Else
palabra = " DIECI"
End If
Case "7"
If catalan Then
palabra = " DISSET"
j = j + 1
i = i + 1
Else
palabra = " DIECI"
End If
Case Else
palabra = IIf(catalan, " DI", " DIECI")
End Select
'fnums10
palabra2 = palabra
Case 9
If gfemenino Then
palabra1 = " UNA"
Else
palabra1 = " UN"
End If
End Select
Case "2"
Select Case i
Case 1
palabra11 = IIf(catalan, " DOS-CENTS", " DOSCIENTOS")
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 2
'nums20
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " VINT-I-", " VEINTI")
Else
palabra = IIf(catalan, " VINT", " VEINTE")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas = 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums20
palabra10 = palabra
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 3
palabra9 = " DOS"
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 4
If gfemenino Then
palabra7 = IIf(catalan, " DUES-CENTES", " DOSCIENTAS")
Else
palabra7 = IIf(catalan, " DOS-CENTS", " DOSCIENTOS")
End If
palabra4 = " MIL"
Case 5
'nums20
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " VINT-I-", " VEINTI")
Else
palabra = IIf(catalan, " VINT", " VEINTE")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas = 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums20
palabra6 = palabra
palabra4 = " MIL"
Case 6
palabra5 = IIf(gfemenino, " DUES", " DOS")
palabra4 = " MIL"
Case 7
If gfemenino Then
palabra3 = IIf(catalan, " DUES-CENTES", " DOSCIENTAS")
Else
palabra3 = IIf(catalan, " DOS-CENTS", " DOSCIENTOS")
End If
Case 8
'nums20
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " VINT-I-", " VEINTI")
Else
palabra = IIf(catalan, " VINT", " VEINTE")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas = 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums20
palabra2 = palabra
Case 9
If catalan And gfemenino Then
palabra1 = " DUES"
Else
palabra1 = " DOS"
End If
End Select
Case "3"
Select Case i
Case 1
palabra11 = IIf(catalan, " TRES-CENTS", " TRESCIENTOS")
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 2
'nums30
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " TRENTA-", " TREINTA Y")
Else
palabra = IIf(catalan, " TRENTA", " TREINTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums30
palabra10 = palabra
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 3
palabra9 = " TRES"
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 4
palabra7 = IIf(catalan, " TRES-CENTES", " TRESCIENTAS")
palabra4 = " MIL"
Case 5
'nums30
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " TRENTA-", " TREINTA Y")
Else
palabra = IIf(catalan, " TRENTA", " TREINTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums30
palabra6 = palabra
palabra4 = " MIL"
Case 6
palabra5 = " TRES"
palabra4 = " MIL"
Case 7
If gfemenino Then
palabra3 = IIf(catalan, " TRES-CENTES", " TRESCIENTAS")
Else
palabra3 = IIf(catalan, " TRES-CENTS", " TRESCIENTOS")
End If
Case 8
'nums30
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " TRENTA-", " TREINTA Y")
Else
palabra = IIf(catalan, " TRENTA", " TREINTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums30
palabra2 = palabra
Case 9
palabra1 = " TRES"
End Select
Case "4"
Select Case i
Case 1
palabra11 = IIf(catalan, " QUATRE-CENTS", " CUATROCIENTOS")
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 2
'nums40
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " QUARANTA-", " CUARENTA Y")
Else
palabra = IIf(catalan, " QUARANTA", " CUARENTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums40
palabra10 = palabra
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 3
palabra9 = IIf(catalan, " QUATRE", " CUATRO")
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 4
palabra7 = IIf(catalan, " QUATRE-CENTES", " CUATROCIENTAS")
palabra4 = " MIL"
Case 5
'nums40
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " QUARANTA-", " CUARENTA Y")
Else
palabra = IIf(catalan, " QUARANTA", " CUARENTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums40
palabra6 = palabra
palabra4 = " MIL"
Case 6
palabra5 = IIf(catalan, " QUATRE", " CUATRO")
palabra4 = " MIL"
Case 7
If gfemenino Then
palabra3 = IIf(catalan, " QUATRE-CENTES", " CUATROCIENTAS")
Else
palabra3 = IIf(catalan, " QUATRE-CENTS", " CUATROCIENTOS")
End If
Case 8
'nums40
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " QUARANTA-", " CUARENTA Y")
Else
palabra = IIf(catalan, " QUARANTA", " CUARENTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums40
palabra2 = palabra
Case 9
palabra1 = IIf(catalan, " QUATRE", " CUATRO")
End Select
Case "5"
Select Case i
Case 1
palabra11 = IIf(catalan, " CINC-CENTS", " QUINIENTOS")
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 2
'nums50
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " CINQUANTA-", " CINCUENTA Y")
Else
palabra = IIf(catalan, " CINQUANTA", " CINCUENTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums50
palabra10 = palabra
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 3
palabra9 = IIf(catalan, " CINC", " CINCO")
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 4
If gfemenino Then
palabra7 = IIf(catalan, " CINC-CENTES", " QUINIENTAS")
Else
palabra7 = IIf(catalan, " CINC-CENTS", " QUINIENTOS")
End If
palabra4 = " MIL"
Case 5
'nums50
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " CINQUANTA-", " CINCUENTA Y")
Else
palabra = IIf(catalan, " CINQUANTA", " CINCUENTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums50
palabra6 = palabra
palabra4 = " MIL"
Case 6
palabra5 = IIf(catalan, " CINC", " CINCO")
palabra4 = " MIL"
Case 7
If gfemenino Then
palabra3 = IIf(catalan, " CINC-CENTES", " QUINIENTAS")
Else
palabra3 = IIf(catalan, " CINC-CENTS", " QUINIENTOS")
End If
Case 8
'nums50
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " CINQUANTA-", " CINCUENTA Y")
Else
palabra = IIf(catalan, " CINQUANTA", " CINCUENTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums50
palabra2 = palabra
Case 9
palabra1 = IIf(catalan, " CINC", " CINCO")
End Select
Case "6"
Select Case i
Case 1
palabra11 = IIf(catalan, " SIS-CENTS", " SEISCIENTOS")
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 2
'nums60
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " SEIXANTA-", " SESENTA Y")
Else
palabra = IIf(catalan, " SEIXANTA", " SESENTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums60
palabra10 = palabra
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 3
palabra9 = IIf(catalan, " SIS", " SEIS")
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 4
If gfemenino Then
palabra7 = IIf(catalan, " SIS-CENTES", " SEISCIENTAS")
Else
palabra7 = IIf(catalan, " SIS-CENTS", " SEISCIENTOS")
End If
palabra4 = " MIL"
Case 5
'nums60
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " SEIXANTA-", " SESENTA Y")
Else
palabra = IIf(catalan, " SEIXANTA", " SESENTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums60
palabra6 = palabra
palabra4 = " MIL"
Case 6
palabra5 = IIf(catalan, " SIS", " SEIS")
palabra4 = " MIL"
Case 7
If gfemenino Then
palabra3 = IIf(catalan, " SIS-CENTES", " SEISCIENTAS")
Else
palabra3 = IIf(catalan, " SIS-CENTS", " SEISCIENTOS")
End If
Case 8
'nums60
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " SEIXANTA-", " SESENTA Y")
Else
palabra = IIf(catalan, " SEIXANTA", " SESENTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums60
palabra2 = palabra
Case 9
palabra1 = IIf(catalan, " SIS", " SEIS")
End Select
Case "7"
Select Case i
Case 1
palabra11 = IIf(catalan, " SET-CENTS", " SETECIENTOS")
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 2
'nums70
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " SETANTA-", " SETENTA Y")
Else
palabra = IIf(catalan, " SETANTA", " SETENTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums70
palabra10 = palabra
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 3
palabra9 = IIf(catalan, " SET", " SIETE")
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 4
If gfemenino Then
palabra7 = IIf(catalan, " SET-CENTES", " SETECIENTAS")
Else
palabra7 = IIf(catalan, " SET-CENTS", " SETECIENTOS")
End If
palabra4 = " MIL"
Case 5
'nums70
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " SETANTA-", " SETENTA Y")
Else
palabra = IIf(catalan, " SETANTA", " SETENTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums70
palabra6 = palabra
palabra4 = " MIL"
Case 6
palabra5 = IIf(catalan, " SET", " SIETE")
palabra4 = " MIL"
Case 7
If gfemenino Then
palabra3 = IIf(catalan, " SET-CENTES", " SETECIENTAS")
Else
palabra3 = IIf(catalan, " SET-CENTS", " SETECIENTOS")
End If
Case 8
'nums70
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " SETANTA-", " SETENTA Y")
Else
palabra = IIf(catalan, " SETANTA", " SETENTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums70
palabra2 = palabra
Case 9
palabra1 = IIf(catalan, " SET", " SIETE")
End Select
Case "8"
Select Case i
Case 1
palabra11 = IIf(catalan, " VUIT-CENTS", " OCHOCIENTOS")
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 2
'nums80
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " VUITANTA-", " OCHENTA Y")
Else
palabra = IIf(catalan, " VUITANTA", " OCHENTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums80
palabra10 = palabra
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 3
palabra9 = IIf(catalan, " VUIT", " OCHO")
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 4
If gfemenino Then
palabra7 = IIf(catalan, " VUIT-CENTES", " OCHOCIENTAS")
Else
palabra7 = IIf(catalan, " VUIT-CENTS", " OCHOCIENTOS")
End If
palabra4 = " MIL"
Case 5
'nums80
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " VUITANTA-", " OCHENTA Y")
Else
palabra = IIf(catalan, " VUITANTA", " OCHENTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums80
palabra6 = palabra
palabra4 = " MIL"
Case 6
palabra5 = IIf(catalan, " VUIT", " OCHO")
palabra4 = " MIL"
Case 7
If gfemenino Then
palabra3 = IIf(catalan, " VUIT-CENTES", " OCHOCIENTAS")
Else
palabra3 = IIf(catalan, " VUIT-CENTS", " OCHOCIENTOS")
End If
Case 8
'nums80
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " VUITANTA-", " OCHENTA Y")
Else
palabra = IIf(catalan, " VUITANTA", " OCHENTA")
If (j = 2 Or j = 1) And (okupas >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums80
palabra2 = palabra
Case 9
palabra1 = IIf(catalan, " VUIT", " OCHO")
End Select
Case "9"
Select Case i
Case 1
palabra11 = IIf(catalan, " NOU-CENTS", " NOVECIENTOS")
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 2
'nums90
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " NORANTA-", " NOVENTA Y ")
Else
palabra = IIf(catalan, " NORANTA", " NOVENTA")
If (j = 2) And (j >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums90
palabra10 = palabra
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 3
palabra9 = IIf(catalan, " NOU", " NUEVE")
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Case 4
If gfemenino Then
palabra7 = IIf(catalan, " NOU-CENTES", " NOVECIENTAS")
Else
palabra7 = IIf(catalan, " NOU-CENTS", " NOVECIENTOS")
End If
palabra4 = " MIL"
Case 5
'nums90
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " NORANTA-", " NOVENTA Y ")
Else
palabra = IIf(catalan, " NORANTA", " NOVENTA")
If (j = 2) And (j >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums90
palabra6 = palabra
palabra4 = " MIL"
Case 6
palabra5 = IIf(catalan, " NOU", " NUEVE")
palabra4 = " MIL"
Case 7
If gfemenino Then
palabra3 = IIf(catalan, " NOU-CENTES", " NOVECIENTAS")
Else
palabra3 = IIf(catalan, " NOU-CENTS", " NOVECIENTOS")
End If
Case 8
'nums90
mas_uno = j + 1
If cifra(mas_uno) <> "0" Then
palabra = IIf(catalan, " NORANTA-", " NOVENTA Y ")
Else
palabra = IIf(catalan, " NORANTA", " NOVENTA")
If (j = 2) And (j >= 8) Then
palabra8 = IIf(catalan, " MILIONS", " MILLONES")
Else
If (j = 1 Or j = 3) And (okupas >= 5) Then
palabra4 = " MIL"
End If
End If
End If
'fnums90
palabra2 = palabra
Case 9
palabra1 = IIf(catalan, " NOU", " NUEVE")
End Select
End Select
i = i + 1
j = j + 1
Loop
If ((palabra10 = " DIECI") Or (palabra10 = " VEINTI")) Or catalan Then
palabra9 = Trim(palabra9)
End If
If ((palabra6 = " DIECI") Or (palabra6 = " VEINTI")) Or catalan Then
palabra5 = Trim(palabra5)
End If
If catalan And Right(palabra2, 1) = "-" Then
palabra1 = Trim(palabra1)
End If

If frase <> "" And decimales <> "00" Then
'IIF(catalan,frase=frase & " AMB ", frase = frase & " CON ")
If catalan Then
frase = frase & " AMB "
Else
frase = frase & " CON "
End If
End If
frase = frase + Trim(palabra11 + palabra10 + palabra9 + palabra8 + palabra7 + _
palabra6 + palabra5 + palabra4 + palabra3 + palabra2 + palabra1)

'decimales = Right(CStr(Me.tbnum.Text), 2)
If z = 0 Then
palabra11 = ""
palabra10 = ""
palabra9 = ""
palabra8 = ""
palabra7 = ""
palabra6 = ""
palabra5 = ""
palabra4 = ""
palabra3 = ""
palabra2 = ""
palabra1 = ""

longitud = Len(decimales)

ReDim cifra(longitud)

For i = 1 To longitud
cifra(i) = Mid(decimales, i, 1)
Next i
i = 9 - longitud + 1
okupas = longitud
j = 1
End If
z = z + 1
Loop

Dim formula As String

formula = "***" & frase & "***"

MsgBox formula

End Sub