Hi All
can someone point me in the right direction, I am writing a little lotto number picker and I want to check the random number generator doesn't select duplicate numbers I tried to do it with a nested for next loop but I couldn't do it. I eventually did it as follows but id doesn't look a good way
Thanks
For j = 0 To 5
temp = Rnd(1,50)
num(j) = temp
Log(num(j))
Next
For i = 0 To 4
If num(i) = num(i+1) Then
Msgbox("error","Error")
Return
End If
Next
For i = 1 To 4
If num(i) = num(i+1) Then
Msgbox("error","Error")
Return
End If
Next
For i = 2 To 4
If num(i) = num(i+1) Then
Msgbox("error","Error")
Return
End If
Next
For i = 3 To 4
If num(i) = num(i+1) Then
Msgbox("error","Error")
Return
End If
Next
End Sub
can someone point me in the right direction, I am writing a little lotto number picker and I want to check the random number generator doesn't select duplicate numbers I tried to do it with a nested for next loop but I couldn't do it. I eventually did it as follows but id doesn't look a good way
Thanks
For j = 0 To 5
temp = Rnd(1,50)
num(j) = temp
Log(num(j))
Next
For i = 0 To 4
If num(i) = num(i+1) Then
Msgbox("error","Error")
Return
End If
Next
For i = 1 To 4
If num(i) = num(i+1) Then
Msgbox("error","Error")
Return
End If
Next
For i = 2 To 4
If num(i) = num(i+1) Then
Msgbox("error","Error")
Return
End If
Next
For i = 3 To 4
If num(i) = num(i+1) Then
Msgbox("error","Error")
Return
End If
Next
End Sub