Error en una SUb con RANDOMIZE
Publicado por TatirusRex (11 intervenciones) el 11/08/2005 16:37:32
Hice este procedimiento para elegir n cantidad de números al azar ingresando un límite inferior y un límite superior, pero me da el error que siempre me incluye el 0(cero) a pesar de estar por fuera de los parametros ingresados, tipo lim, inf. 10 y sup 100, igual me da el cero entre los elegidos y no se como solucionarlo.Me pueden dar una MANO?????
este es el SUB
Public Sub Random()
Dim miValor As Integer
Dim Límite_Superior As Integer, límite_inferior As Integer
Dim Listado As String, n As Integer, Conter As Integer
Listado = " "
n = InputBox("Ingrese la cantidad de registros a elegir al azar", _
"Random - n ")
Límite_Superior = InputBox("Ingrese el Límite Superior", _
"Random - Límite_Superior")
límite_inferior = InputBox("Ingrese el Límite Inferior", _
"Random - Límite_Inferior")
Conter = 0
Do Until Conter = n
Conter = Conter + 1
Listado = Listado & " - " & miValor
Randomize
miValor = Int((Límite_Superior - límite_inferior + 1) * Rnd + límite_inferior)
Loop
MsgBox "Solicitaste " & n & " números elegidos al azar con un" & _
vbCrLf & "Límite Superior =" & Límite_Superior & vbCrLf & _
" y un Límite Inferior = " & límite_inferior & vbCrLf & _
"Los números son: " & Listado
End Sub
este es el SUB
Public Sub Random()
Dim miValor As Integer
Dim Límite_Superior As Integer, límite_inferior As Integer
Dim Listado As String, n As Integer, Conter As Integer
Listado = " "
n = InputBox("Ingrese la cantidad de registros a elegir al azar", _
"Random - n ")
Límite_Superior = InputBox("Ingrese el Límite Superior", _
"Random - Límite_Superior")
límite_inferior = InputBox("Ingrese el Límite Inferior", _
"Random - Límite_Inferior")
Conter = 0
Do Until Conter = n
Conter = Conter + 1
Listado = Listado & " - " & miValor
Randomize
miValor = Int((Límite_Superior - límite_inferior + 1) * Rnd + límite_inferior)
Loop
MsgBox "Solicitaste " & n & " números elegidos al azar con un" & _
vbCrLf & "Límite Superior =" & Límite_Superior & vbCrLf & _
" y un Límite Inferior = " & límite_inferior & vbCrLf & _
"Los números son: " & Listado
End Sub
Valora esta pregunta


0