We could put in 100 lines to generate the random number and 100 lines to add it to the list box or we can just make use of a FOR…NEXT loop.
This unconditional loop uses an incrementing counter (called counter in the example program) to control the number of repetitions of the loop. Everything between the FOR and NEXT lines is repeated.
What would happen if we wanted to check that the random number generator was really random? How could we test that the numbers are random? Answer after the jump.
We can make use of a loop to roll a large number of dice and we can then check the outcome of the roll. If we count the number of occurrences of each number in each roll we can check if they are broadly equal, this should mean that they are random. A large sample size will be needed.
The ” DIM NoOf1s as Integer = 0 ” lines create the variable and set (initialise) the value to zero. It is important to realise that zero is not the same as nothing (NULL).
The for loop is used to roll six thousand dice.
The IF statements check the result then count up (increment) the number of times they appear.
Finally the answers are displayed.