1 Reply Latest reply on Mar 11, 2010 11:05 AM by Sean_Wilson

# Lottery Selection

Hi I am relatively new to using lingo and i am having a bit of a problem

I have created a piece of code that puts a random numbers (1 to 49) into six boxes and named num 1 to num 6 when a button is pressed

the code for  this is as follows:

on mouseup

repeat with i=1 to 6

lvno=random(49)

Member("num"&i).text=string(lvno)

end repeat

end

However this does mean that ocassionally two boxes show up the same number does anyone know how to have each box check if the others has the same number and if it does to change it to another random number.

• ###### 1. Re: Lottery Selection

A simple option is to place your generated numbers into a list. Then when you get a new number, check to see whether it's already in the list and if so get one again.

``` on mouseUp me
lNumbers = []
repeat with i=1 to 6
repeat while TRUE
lvno=random(49)
if lNumbers.getPos(lvno) then next repeat
exit repeat
end repeat
lNumbers.append(lvno)
Member("num"&i).text=string(lvno)
end repeat
end
```