I am trying to create an array of numbers that are not repeated. The order of priority is from top to bottom, left to right, where I'm trying to get a range of x to y. But need dont be repeat values in ranges
Dim arrayCarton(9, 3) As Integer
Private Sub generar_carton()
Randomize()
filas = 3
columnas = 9
Dim RandomNumber As Integer
For j = 0 To columnas - 1
For i = 0 To filas - 1
Dim label As Label = CType(Panel2.Controls("Carton" & i & j), Label)
If j = 0 Then
RandomNumber = CInt(Math.Floor(((9 * (j + 1)) - 1) * Rnd())) + 1
End If
If j < 8 And j > 0 Then
RandomNumber = CInt(Math.Floor(((j * 10 + 9) - j * 10) * Rnd())) + j * 10
End If
If j = 8 Then
RandomNumber = CInt(Math.Floor(((9 * 10) - j * 10) * Rnd())) + j * 10 + 1
End If
arrayCarton(j, i) = RandomNumber
label.Text = arrayCarton(j, i)
Next
Next
End Sub
One can see that some numbers are repeated, output:
Aucun commentaire:
Enregistrer un commentaire