Discussion Locked

How do i retrieve a record from a database randomly?

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Hi, I am developing a test ingine to run online testing software and i have one problem, i just cant seem to load the questions randomly from the database so that the exams dont look similar everytime they are loaded. can someone please help?

2 replies

by fred_krampe

use the random number generator (which generates a number between 0 and 1)and combine with the max record in the table.

See my example (not tested) below:
========================================
Use myTable

** init randomizer
=Rand(-1)

** set the number of questions to ask
nAsk = 20

For i = 1 To nAsk

nRec = Int(Reccount()* Rand()) + 1

Go nRec

?myTable.Question
Endfor
======================================

This discussion is closed to new replies.