ayuudaaaaaaaaaaaaaaaaaaaaaaaaaa, no se como hacer ese programa, necesito ayuda plis, alguien podra ayudarmee?????, me urge su apoyo, gracias mi mail cecypompis@hotmail.com
ayuudaaaaaaaaaaaaaaaaaaaaaaaaaa, no se como hacer ese programa, necesito ayuda plis, alguien podra ayudarmee?????, me urge su apoyo, gracias mi mail cecypompis@hotmail.com
hola,
Crea un modulo y pega esto :
'---------------------------------------------------------------------------
' gsNumero.BAS Módulo para procedimientos numéricos ( 1/Mar/91)
' Versión para Windows (25/Oct/96)
'
' (c)Guillermo Som, 1991-97
'---------------------------------------------------------------------------
Option Explicit
Option Compare Text
Public Function Numero2Letra(ByVal strNum As String, Optional vLo) As String
'----------------------------------------------------------
' Convierte el número strNum en letras (28/Feb/91)
' Versión para Windows (25/Oct/96)
'----------------------------------------------------------
Dim lngA As Long
Dim Negativo As Boolean
Dim L As Integer
Dim Una As Boolean
Dim Millon As Boolean
Dim Millones As Boolean
Dim vez As Integer
Dim MaxVez As Integer
Dim k As Integer
Dim strQ As String
Dim strB As String
Dim strU As String
Dim strD As String
Dim strC As String
Dim iA As Integer
'
Dim strN() As String
Dim lo As Integer
'
'Si no se especifica el ancho...
If IsMissing(vLo) Then
lo = 255
Else
lo = vLo
End If
Dim unidad(0 To 9) As String
Dim decena(0 To 9) As String
Dim centena(0 To 9) As String
Dim deci(0 To 9) As String
Dim otros(0 To 15) As String
'Asignar los valores
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) = "doscientas"
centena(3) = "trescientas"
centena(4) = "cuatrocientas"
centena(5) = "quinientas"
centena(6) = "seiscientas"
centena(7) = "setecientas"
centena(8) = "ochocientas"
centena(9) = "novecientas"
'
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"
'
On Error GoTo 0
lngA = Abs(Val(strNum))
Negativo = (lngA <> Val(strNum))
strNum = LTrim$(RTrim$(Str$(lngA)))
L = Len(strNum)
If lngA = 0 Then
strNum = Left$("cero" & Space$(lo), lo)
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(1 To 4)
strQ = Right$(String$(12, "0") & strNum, 12)
For k = Len(strQ) To 1 Step -3
vez = vez + 1
strN(vez) = Mid$(strQ, k - 2, 3)
Next
MaxVez = 4
For k = 4 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 = Val(Right$(strNum, 2))
If Right$(strNum, 1) = "0" Then
k = k \ 10
strD = decena(k)
ElseIf k > 10 And k < 16 Then
k = Val(Mid$(strNum, L - 1, 2))
strD = otros(k)
Else
strU = unidad(Val(Right$(strNum, 1)))
If L - 1 > 0 Then
k = Val(Mid$(strNum, L - 1, 1))
strD = deci(k)
End If
End If
If L - 2 > 0 Then
k = Val(Mid$(strNum, L - 2, 1))
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) And strN(vez + 1) <> "000" Then strB = " mil " & strB
If vez = 2 And Millon Then
If Millones Then
strB = " millones " & strB
Else
strB = "un millón " & strB
End If
End If
Next
strB = LTrim$(RTrim$(strB))
If Right$(strB, 3) = "uno" Then strB = Left$(strB, Len(strB) - 1) & "a"
Do 'Quitar los espacios que haya por medio
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
'
strC = Space$(lo)
LSet strC = strB
Numero2Letra = strC
End Function
Imaginando que tienes un text1 con el numero a convertir, un text2 donde se visualizara en letras y un botón command1 que ejecuta la conversión.
Deberás llamar a la función en el procedimiento click del botón convertir:
Private Sub Command1_Click()
'Convertir en letras el número en Text1
Dim Numero As String
Dim Letras As String
Numero = CStr(Val(Text1.text))
Text2.text = Numero2Letra(Numero) ' Llamada a la función que 'devolverá el numero en letras.
End Sub
Si quieresdescargar un ejemplo de este mismo codigo entra aqui :
http://www.elguille.info/vb/VB_PRG.HTM#Num2Letra
Espero que te sirva.Edited by: Naisha