A very useful function that is available in most programming languages is one that generates random numbers. It must be noted however, that is only creates pseudo-random numbers and cannot be relied upon to give fair results.
The function Rnd will generate a randomly single number between 0 and 1. To create and integer number, the value must be multiplied by an integer and convert the result to an integer. .
Num = Int(6*Rnd)+1 will produce a random numbers between 1 and 6.
A primary school teacher needs a program that will test a students addition skills. The program generates 4 simple addition problems and determines the number of correct answers.

The main plan for this as follows. Data is obtained using an input box and results shown by a message box. Labels are used to display the number of correct answers and the number of questions asked.
Set Correct To 0
For Count <- 1 To 4
Set Number1 To Int(10 * Rnd) + 1
Set Number2 To Int(10 * Rnd) + 1
Set Sum To Number1 + Number2
Get Answer
If Answer = Sum Then
Write well done
Set Correct To Correct + 1
Write Number correct
Else
Write Wrong
End If
Write Number Completed
Next Count
Note: The function Randomize is used in one of the first lines of the program to enable the program to start with a different random number each time the program is run.
The important controls are the command button (CmdAdd)to start the Set of questions and two labels that update the number correct (LblCorrect) and the number of questions given (LblCompleted). The rest of the design should be straight forward.
Private Sub CmdAdd_Click()
Const max = 4
Dim Number1 as Integer, Number2 as Integer
Dim Sum as Integer, Answer as Integer
Dim Correct As Integer, Count As Integer
dim txtanswer as string
Randomize
Correct = 0
LblCorrect.text = "Number correct is " & Correct & "/" & max
LblCompleted.text = "Number Completed is 0/" & max
For Count = 1 To max
Number1 = Int(10 * Rnd) + 1
Number2 = Int(10 * Rnd) + 1
Sum = Number1 + Number2
txtAnswer = InputBox(Number1 & " + " & Number2 & " =", "Maths Adder", 0, 2000, 3000)
answer = CInt(txtAnswer)
If Answer = Sum Then
MsgBox ("well done")
Correct = Correct + 1
LblCorrect.text = "Number correct is " & Correct & "/" & max
Else
MsgBox ("Wrong - answer is " & Sum)
End If
LblCompleted.text = "Number Completed is " & Count & "/" & max
Next Count
End Sub