EscapeTheFate Posted March 2, 2008 Share Posted March 2, 2008 If I run Random in a loop it returns the original random number it returned. I need random in a loop, so is there anyway to run it without it returning the same number over and over again? While 1 msgBox(0, "Roll of die", "You rolled a " & Random(1, 6, 1) ) WEnd Link to comment Share on other sites More sharing options...
covaks Posted March 2, 2008 Share Posted March 2, 2008 The code you posted does not return the same number over and over again for me. Each time the message box pops up, I get a different number from 1 to 6. Is it returning the same number for you every time the message box pops up?? Or is that not what you meant? You could also toss an Srandom in the loop if that helps, but it shouldn't be returning the same number over and over again. Link to comment Share on other sites More sharing options...
JustinReno Posted March 2, 2008 Share Posted March 2, 2008 So, I'm guessing the OP only ran the code twice and got the same number? Link to comment Share on other sites More sharing options...
rasim Posted March 2, 2008 Share Posted March 2, 2008 If I run Random in a loop it returns the original random number it returned. I need random in a loop, so is there anyway to run it without it returning the same number over and over again? While 1 msgBox(0, "Roll of die", "You rolled a " & Random(1, 6, 1) ) WEnd This?: #include <Array.au3> Global $aNumber[7] $aNumber[0] = 6 For $i = 1 To $aNumber[0] While 1 $iRandom = Random(1, 6, 1) _ArraySearch($aNumber, $iRandom, 1) If @error Then ExitLoop WEnd $aNumber[$i] = $iRandom MsgBox(0, "Random", $iRandom) Next Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now