Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I've been making a quiz using vb.net
Please help me

What I have tried:

So far I have only tried the Select class rnd.Next (0, 5)
Posted
Updated 24-Mar-17 1:21am
Comments
F-ES Sitecore 24-Mar-17 7:53am    
Keep a record of the random numbers that have already been picked, and if you pick a number that has already been picked pick another one until you get one that hasn't been picked. When you have your new unique number add it to the list of already picked numbers. That's probably the simplest way to do it, though probably not the most efficient.

1 solution

Don't. Use one form, but randomise the data you load into it - don't try to create a new form for each question!

Then it's pretty simple: create a set of questions, with the answer (or answers) and keep a record in your app of which questions you have already asked. That's not difficult - the simplest way is to create a text file which has a line per question, with questions and answers separated by '|' characters:
question|CorrectAnswerNumber|Answer1|Answer2|Answer3
question|CorrectAnswerNumber|Answer1|Answer2|Answer3
question|CorrectAnswerNumber|Answer1|Answer2|Answer3
...
You can then read them all into an Array of String using File.ReadAllLines, and separate each line into questions and answers using string.Split.
Keep a separate collection of question numbers you have asked, and you can select a question at random from the array of strings. Split that line, and fill in the fields on the current form.

But... this is your homework, so I'll give you no code!
It's pretty simple if you think about it for a bit and try a few experiments.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900