Click to See Complete Forum and Search --> : visual basic


hmurti17
April 1st, 2001, 03:09 AM
I am doing a project on online examination. I have entered data (questions) into the database. I would be thankful if anybody can suggest the code for automatically radom selection of questions when a student appears for the test.

Thanks.

shree
April 1st, 2001, 07:59 AM
I fyou have an autoincrement field in your database, then it is easy.

Determine a random number using

QNo = Int (Rnd*NoOfQuestions)+1

Then use FindFirst to determine the record with this number in the ID field

But it might result in the same question number being repeated again. To prevent this


dim UsedNum as string

for i=1 to 10 'to select ten questions
do
QNo = Int (Rnd*NoOfQuestions)+1
Loop until Instr(UseNum, QNo & ", ")=0
UsedNum = UsedNum & QNo & ", "
'Do other work here
next