I have a code to display a non-repeating random numbers, but I stuck by not sort in ascending order.
Here my code:
Public Class Form1
Dim intNumber As Integer
Dim arrNumber(0 To 5) As Integer
Dim i, x, y As Integer
Private Sub mostrar_resultados_sorteo(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
repetido()
For i = 0 To 5
ListBox1.Items.Add(arrNumber(i).ToString)
Next
End Sub
Private Sub repetido()
For x = 0 To 5
Start:
Randomize()
intNumber = Int((49 * Rnd()) + 1)
For y = 0 To 5
If intNumber = arrNumber(y) Then
GoTo Start
End If
Next y
arrNumber(x) = intNumber
Next x
ordenar()
End Sub
Private Sub ordenar()
End Sub
End Class
Aucun commentaire:
Enregistrer un commentaire