Page 1 of 1

Quiz Game

PostPosted: Sat Sep 12, 2009 1:26 pm
by jman
hi i am going to make a quiz game and i have a question... how would you make each question come up randomly??
all help appreciated :D

Re: Quiz Game

PostPosted: Sat Sep 12, 2009 2:23 pm
by skydereign
You would use rand. Just say you have a data base of questions, maybe held by an array. On the event that pulls up questions, it would do something like this.
Code: Select all
int randomQ = rand(2);
switch(randomQ)
{
    case 0:
    strcpy(textActor.text, "Question number one is?");
    break;

    case 1:
    strcpy(textActor.text, "Does this make sense?");
    break;
}


It may differ, but this is the general idea. So you know, rand picks a random number from zero to the int one less than the number, so in this case 0 or 1. Since it can be only two possibilities, I have two cases in the switch statement, but you would have more, one for each question.

Re: Quiz Game

PostPosted: Sat Sep 12, 2009 3:15 pm
by jman
ty.. :D :D :D

PS: do you sit on the computer all day just to answer all of my questions?? :lol: :lol: :lol:

keep up the good work

Re: Quiz Game

PostPosted: Tue Sep 15, 2009 5:19 am
by fuentesmith
There is one inbuilt function in VB.net named Random. With the help of the Random Function, each time a random number is selected from the list of numbers.