Need To Make A Quiz!

murtz
12-05-2004, 04:43 PM
hey, this is my first time on this board so im an amateur!

i need to make a quiz using visual basic.net. and im really finding it difficult to do some of the stuff needed to do!

basically the quiz needs to have 10 questions (of my choice), and only one question can be displayed at a time (i was thinking of using group boxes on the form but aint too sure!)..each question has a set timer which has to be displayed (eg 20 seconds)...and when the time runs out a message boxs tells you so, and the next question is displayed. also, when you select an answer, it tells you in a message box if ur correct or wrong..and at the end of the questions you get a total score.

i know it sounds complicated, well it does to me, so if anyone could give any pointers or any sort of help towards it id be really grateful!

thanx :)

excaliber
12-05-2004, 04:53 PM
Do you have a specific question? We don't write out code for people, just help them with problems they may be having.

murtz
12-05-2004, 05:18 PM
yeah, basically at the moment im able to have a message box appear after 10 seconds, but i cant get a 10 second timer to appear in a label showing the countdown.

also, i dont know how to have one question appear at a time, and after the timer ends, another one appearing.

thanx

Iceplug
12-05-2004, 06:29 PM
For the timer, you should use a timer control.
You can set the interval property to 1000 (for 1 second) and then declare a variable which holds the counter.
So, the timer would decrease the value of the counter by 1 everytime it runs.
The interval is 1000, so the counter decreases once every second.
You can put the counter result into the label to see the countdown.

As for getting one question to appear at a time, that depends mostly on how you are displaying the labels. This shouldn't be a problem if you are just assigning texts to controls on your form. :)

murtz
12-05-2004, 06:42 PM
ok, i get what you mean Iceplug...this is the coding i have so far. i have included two timers.

Private Sub InitializeTimer()

counter = 0
Timer1.Interval = 10000
Timer2.Interval = 1000
Timer1.Enabled = True
Timer2.Enabled = True

End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
MessageBox.Show("Ran Out Of Time")
Timer1.Start()

If counter >= 10 Then
Timer1.Enabled = False
counter = 0
Else

counter = counter + 1
Label1.Text = "Time Remaining: " & counter.ToString



End If
End Sub


Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If counter >= 10 Then
Timer1.Enabled = False
counter = 0
Else

counter = counter + 1
Label1.Text = "Time Remaining: " & counter.ToString
End If
End Sub

this code shows the time going up from 1 to 10, and then i get a message box saying 'ran out of time'...but the timer starts again automatically without me even clicking ok on the message box. also, after the restart of the timer, i dont get the message box again, it only comes up in the first 10 seconds!.

as for the one question appearing at a time, im going to be using group boxes to show each question, how can i show each group box 1 at a time?

thanx for all the help by the way!

murtz
12-05-2004, 06:51 PM
ok i think i sorted the part about the message box only coming up once, here is my code now..

Private Countdown As String

Private Sub InitializeTimer()
Countdown = 0
Timer1.Interval = 10000
Timer2.Interval = 1000
Timer1.Enabled = True
Timer2.Enabled = True

End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
MessageBox.Show("Ran Out Of Time")
Timer1.Start()


End Sub


Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If Countdown >= 10 Then
Timer1.Enabled = False
Countdown = 0
Else
Countdown = Countdown + 1
Label1.Text = "Time Remaining: " & Countdown.ToString
End If
End Sub

End Class


the message box comes up every 10 seconds, but because im using two timers, i dont think they interact with each other, as in when the timer reaches 10, the message box comes up, and when i click ok, the timer restarts. the way ive done it makes the timer keep on restarting by itself.

please help on the 1 question appearing at a time part aswell.

thankyou

Iceplug
12-06-2004, 06:52 AM
how can i show each group box 1 at a time?
Why do you have more than one group box?

Come to think of it, why do you need more than one timer?

If you have ten groupboxes, you are going to have to laboriously set all of their visible properties.
GB1.Visible = False
GB2.Visible = True
GB3.Visible = False
GB4.Visible = False
GB5.Visible = False
GB6.Visible = False
GB7.Visible = False
GB8.Visible = False
GB9.Visible = False
GB10.Visible = False
'This is to make the second groupbox visible.
If you want the third to be visible, set all groupboxes' visible property to false and then set the third one to be visible = true :).

murtz
12-06-2004, 04:25 PM
well im using two timers because one is for the message box to come up when the 10 seconds is over, and the other timer is for the actual countdown to be shown on the screen...i dont know how to combine the two though!.

at the moment, most of the things are working, but when you load the form, theres a button that you have to click to actually start the quiz... but i dont know how to get the timer to start AFTER you click that button.

and one last thing, i also need the user to be able to choose how much time he wants on each question before he starts the quiz lol.

thanx for all the help iceplug really appreciate it, if you can help me on these then please do!..thanx!

gravity7
12-06-2004, 05:36 PM
well im using two timers because one is for the message box to come up when the 10 seconds is over, and the other timer is for the actual countdown to be shown on the screen...i dont know how to combine the two though!.

at the moment, most of the things are working, but when you load the form, theres a button that you have to click to actually start the quiz... but i dont know how to get the timer to start AFTER you click that button.

and one last thing, i also need the user to be able to choose how much time he wants on each question before he starts the quiz lol.

thanx for all the help iceplug really appreciate it, if you can help me on these then please do!..thanx!

Set:

Timer.enabled = True

to activate the timer. Place this code in the Button_Click() event procedure and it will start the timer when the button is clicked.

Use a variable to hold the maximum
time from the input form and then use that variable to change the timer control parameters.

Iceplug
12-06-2004, 07:26 PM
You need to have some kind of control that can accept a value that the user specifies (example: NumericUpDown, TrackBar, TextBox)
When you change the value in either control, assign it to a variable.

Dim V As Decimal
and then assign the value to V.
And then, you can use this value of V to check when the countdown is over...
which brings me back to the timers.

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
MessageBox.Show("Ran Out Of Time")
Timer1.Start() 'why?

End Sub


Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If Countdown >= 10 Then
Timer1.Enabled = False 'why?
Countdown = 0
Else
Countdown = Countdown + 1
Label1.Text = "Time Remaining: " & Countdown.ToString
End If
End Sub

This seems to rely heavily on Timer1 firing before Timer2.
The only thing that Timer1 is doing is displaying a MessageBox. Everything else occurs in Timer2.
You could easily display the messagebox in Timer2.

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If Countdown >= 10 Then
MessageBox.Show("Ran Out Of Time") 'why not?
Countdown = 0
Else
Countdown = Countdown + 1
Label1.Text = "Time Remaining: " & Countdown.ToString
End If
End Sub

Here, you can easily control the timeout by V... just replace 10 with V. :)

murtz
12-06-2004, 09:21 PM
thanx iceplug and gravity7!...you guys have helped me out alot!...really appreciate it!...i dont think i have any more problems but ill add to the board if i do!

thanx a bunch once again!

murtz
12-09-2004, 01:31 PM
ive nearly finished making the quiz, just got one more problem, i dont know how to make a 'Results Page' at the end...i need to add all the right answers up to give a total, please help!

Iceplug
12-09-2004, 07:35 PM
Why not have a variable declared in your form of which, when you get a question right, you increment the value? :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum