B4A Class [B4X] Class - clsRndItems

A simple class for randomly picking items from a group without repetitions (but also with repetitions, if desired).
It works on all platforms (B4A, B4J, B4I), of course.

Main methods:

Initialize(..., NumOfItems As Int)
Creates, by default, a list of numeric items, from 1 to NumOfItems you will provide.
You can change next the total number of Items using the "NumOfItems" property.
You can also set a list of Items of any size and type using the "Items" property.

Returns a random item among those still available, making it no longer available.
Useful to get unique Items.

Returns a random item among those still available, without removing it.

Returns a random item among all existing ones (not only among those still available),
without removing it.

Makes all the previously "popped" items available again.


  • RndItems.zip
    15 KB · Views: 222
  • clsRndItems.bas
    3.1 KB · Views: 222
Last edited: