Fijate si te sirve. Copiá y pegá todo esto en una página que se llame "monto_escrito.asp" y probalo: <html>
<head>
<title>Monto escrito</title>
</head>
<body>
<p align="center"><b><font face="Verdana">Convertidor de números a su valor en
letras<br>
By <a href="http://www.forosdelweb.com/member.php?s=&action=getinfo&userid=35429">Inutil</a></font></b></p>
<p>_</p>
<form action="monto_escrito.asp" method="POST" name="Form" id="Form">
<p><font face="Verdana" size="1">Escriba sólo números enteros, sin
puntuación de miles:</font><br>
<input type="text" name="NUMERO" size="40" style="font-family: Verdana; font-size: 8 pt">
<input type="submit" value="Dale gas!" name="B1" style="font-family: Verdana; font-size: 8 pt"></p>
</form>
<p>
<font face="Verdana" size="2">
<%
on error resume next
Accion = Request.Form("NUMERO")
numero_prueba = Accion
numero_prueba = FormatNumber(numero_prueba,0)
If Accion = "" then
Else
%>
<%
dim unidad(9), decena(9), centena(10), deci(9), otros(15)
Sub InicializarArrays()
unidad(1) = "una" & " "
unidad(2) = "dos" & " "
unidad(3) = "tres" & " "
unidad(4) = "cuatro" & " "
unidad(5) = "cinco" & " "
unidad(6) = "seis" & " "
unidad(7) = "siete" & " "
unidad(8) = "ocho" & " "
unidad(9) = "nueve" & " "
'
decena(1) = "diez" & " "
decena(2) = "veinte" & " "
decena(3) = "treinta" & " "
decena(4) = "cuarenta" & " "
decena(5) = "cincuenta" & " "
decena(6) = "sesenta" & " "
decena(7) = "setenta" & " "
decena(8) = "ochenta" & " "
decena(9) = "noventa" & " "
'
centena(1) = "ciento" & " "
centena(2) = "doscientos" & " "
centena(3) = "trescientos" & " "
centena(4) = "cuatrocientos" & " "
centena(5) = "quinientos" & " "
centena(6) = "seiscientos" & " "
centena(7) = "setecientos" & " "
centena(8) = "ochocientos" & " "
centena(9) = "novecientos" & " "
centena(10) = "cien" & " "
'
deci(1) = "dieci" & " "
deci(2) = "veinti"' & " "
deci(3) = "treinta" & " " &"y" & " "
deci(4) = "cuarenta" & " " &"y" & " "
deci(5) = "cincuenta" & " " &"y" & " "
deci(6) = "sesenta" & " " &"y" & " "
deci(7) = "setenta" & " " &"y" & " "
deci(8) = "ochenta" & " " &"y" & " "
deci(9) = "noventa" & " " &"y" & " "
'
otros(1) = "1"
otros(2) = "2"
otros(3) = "3"
otros(4) = "4"
otros(5) = "5"
otros(6) = "6"
otros(7) = "7"
otros(8) = "8"
otros(9) = "9"
otros(10) = "10"
otros(11) = "once" & " "
otros(12) = "doce" & " "
otros(13) = "trece" & " "
otros(14) = "catorce" & " "
otros(15) = "quince" & " "
End Sub
Function Numero2Letra(strNum , vLo, vMoneda, vCentimos)
If vMoneda<>"" Then
sMoneda = " " & Trim(vMoneda) & " "
Else
sMoneda = " "
End If
If vCentimos<>"" Then
sCentimos = " " & Trim(vCentimos)
End If
sNumero = Format(25.5, "#.#")
If InStr(sNumero, ".") Then
sDecimal = "."
Else
sDecimal = ","
End If
If IsMissing(vLo) Then
Lo = 0
Else
Lo = vLo
End If
'
If Lo Then
sNumero = Space(Lo)
Else
sNumero = ""
End If
Do
i = InStr(strNum, " ")
If i = 0 Then Exit Do
strNum = Left(strNum, i - 1) & Mid(strNum, i + 1)
Loop
iHayDecimal = InStr(strNum, sDecimal)
If iHayDecimal Then
sEntero = Left(strNum, iHayDecimal - 1)
sFraccion = Mid(strNum, iHayDecimal + 1) & "00"
sFraccion = Left(sFraccion, 2)
fFraccion = sFraccion
If fFraccion < 1 Then
strNum = RTrim(UnNumero(sEntero) & sMoneda)
sNumero = strNum
Numero2Letra = sNumero
Exit Function
End If
sEntero = UnNumero(sEntero)
sFraccion = UnNumero(sFraccion)
'
strNum = sEntero & sMoneda & "con " & sFraccion & sCentimos
sNumero = RTrim(strNum)
Numero2Letra = sNumero
Else
strNum = RTrim(UnNumero(strNum) & sMoneda)
sNumero = strNum
Numero2Letra = sNumero
End If
End Function
Function UnNumero(strNum)
Const cAncho = 12
cGrupos = cAncho / 3
lngA = Abs(CDbl(strNum))
Negativo = (lngA <> CDbl(strNum))
strNum = LTrim(RTrim(cStr(lngA)))
L = Len(strNum)
If lngA < 1 Then
UnNumero = "cero"
Exit Function
End If
Una = True
Millon = False
Millones = False
If L < 4 Then Una = False
If lngA > 999999 Then Millon = True
If lngA > 1999999 Then Millones = True
strB = ""
strQ = strNum
vez = 0
ReDim strN(cGrupos)
strQ = Right(String(cAncho, "0") & strNum, cAncho)
For k = Len(strQ) To 1 Step -3
vez = vez + 1
strN(vez) = Mid(strQ, k - 2, 3)
Next
MaxVez = cGrupos
For k = cGrupos To 1 Step -1
If strN(k) = "000" Then
MaxVez = MaxVez - 1
Else
Exit For
End If
Next
For vez = 1 To MaxVez
strU = "": strD = "": strC = ""
strNum = strN(vez)
L = Len(strNum)
k = Right(strNum, 2)
If Right(strNum, 1) = "0" Then
k = cInt(k) / 10
strD = decena(k)
ElseIf k > 10 And k < 16 Then
k = Mid(strNum, L - 1, 2)
strD = otros(k)
Else
strU = unidad(Right(strNum, 1))
If L - 1 > 0 Then
k = Mid(strNum, L - 1, 1)
strD = deci(k)
End If
End If
If L - 2 > 0 Then
k = Mid(strNum, L - 2, 1)
If k = 1 Then
If strNum = 100 Then
k = 10
End If
End If
strC = centena(k) & " "
End If
If strU = "uno" And Left(strB, 4) = " mil" & " " Then strU = ""
strB = strC & strD & strU & " " & strB
If (vez = 1 Or vez = 3) Then
If strN(vez + 1) <> "000" Then strB = " mil" & " " & strB
End If
If vez = 2 And Millon Then
If Millones Then
strB = " millones" & " " & strB
Else
strB = "un" & " " & "millón" & " " & strB
End If
End If
Next
strB = Trim(strB)
If Right(strB, 3) = "uno" Then strB = Left(strB, Len(strB) - 1) & "a"
Do
iA = InStr(strB, " ")
If iA = 0 Then Exit Do
strB = Left(strB, iA - 1) & Mid(strB, iA + 1)
Loop
If Left(strB, 6) = "una un" Then strB = Mid(strB, 5)
If Left(strB, 7) = "una mil" Then strB = Mid(strB, 5)
If Right(strB, 16) <> "millones mil una" Then
iA = InStr(strB, "millones mil una")
If iA Then strB = Left(strB, iA + 8) & Mid(strB, iA + 13)
End If
If Right(strB, 6) = "ciento" Then strB = Left(strB, Len(strB) - 2)
If Negativo Then strB = "menos " & strB
UnNumero = Trim(strB)
End Function
InicializarArrays
Response.Write(Numero_Prueba & ": " & unNumero(Accion) & "<br>")
'Response.Write(": " & unNumero(Accion) & "<br>")
Response.Write("1: " & unNumero(1) & "<br>")
%>
<%
End if
%>
</font>
</p>
<p>_</p>
</body>
</html>
Saludos |