Trivia--Randomize Questions

Dodgeram01

Active member
Joined
Apr 9, 2002
Messages
41
Location
Upstate NY
I am in the process of making a Console app which will ask trivial questions (ATV specs mostly). Anyways, Ive done a little work with the Random object, and was wondering how one would possibly going about using it so that the program will ask the questions in a random order. Thanks.
 
Code:
Imports System

Dim sQuestions() As String = {"Question 1", "Question 2", "Question 3"}

Dim r As New Random(DateTime.Now.Ticks)

Dim nElement As Decimal = r.Sample * sQuestions.GetUpperBound(0)

Console.WriteLine(sQuestions(Decimal.ToInt32(nElement)).ToString)
 
Crazed Lunatic, I dont quite understand the sample. :( Also, the complier didnt like the r.sample line.

My code basically looks like this:

Code:
Console.WriteLine("SP4-What size pilot jet does a Sportsman 400 have?")
        answer = Console.ReadLine
        If answer = 40 Then
            Points = Points + 1
Points is a counter
            Console.WriteLine("Correct! Total Points: " & Points) 
            Console.ReadLine()
        Else
            Console.WriteLine("Incorrect! Answer is: 40")
            Console.WriteLine("Total Points: " & Points)
            Console.ReadLine()
        End If

I put the Console.Readlines in there so that the application would pause, and wait for the user to press a key to continue. Im not sure if theres a better way to do that though.

Back to the subject, Im not sure like if I should put each question and its answer logic in separate subs, or what the deal is with it. Thank you.
 
Back
Top