Using Rnd with specific numbers rather than a range

MDEnt

Member
Licensed User
Longtime User
Is it possible to generate a random integer from a list of numbers or predefined set - that may not be in order.

For example - generate a random number from 1,2,4,5 (no 3 allowed).
 
Last edited:

MDEnt

Member
Licensed User
Longtime User
Thanks...makes sense, is there specific sytnax to use Rnd in this case? - I'm actually going to use a list from an Array.

cardsLST.AddAll(Array As Int(1,2,4,5))
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
Or better
B4X:
cardsLST.Get(Rnd(0,cardsLST.Length))

Then the list of numbers can be any size
 
Upvote 0

MDEnt

Member
Licensed User
Longtime User
Thanks so much - I'm going to play around with both - I'm sure both will come in handy!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…