1

I'm a first year student in university and i'm in the process of learning Visual Studio and I'm trying to build a Quiz.

The quiz has 10 questions - Created in 10 different forms Each form design also has panel with 10 radio buttons (labeled Question 1 - Question 10) when a radio button is selected i.e. Question 2, will hide the existing form, and open up the form2 which is for Question 2. Each form design has the buttons NEXT, PREVIOUS and SUBMIT.

  • Hitting NEXT will go to the next question (i.e. if currently on form 1 next will go to form 2 and so on.)
  • The SUBMIT button will only be enabled AFTER all 10 questions have been answered, and will go to FORM 11 (Summary of Quiz).

I'm having a problem here. The intended outcome should be:

  • When Hitting PREVIOUS button, it should open the last form hidden.

I've only come across ways to use a button to go to specific forms that have been defined, but is there a way that the button is able to identify the last form opened?

i.e. Using this code, when I click the button, it hides the current form, and shows a specific form that has been defined. But I can't use this for the outcome I want.

Form1.Hide() Form2.Show()

Intended Outcome

  • i.e. I start the application, it's in form 1. I select Radio Button with label Question 9, where it hides form 1 and opens form 9 (Question 9)
  • I select Radio Button with label Question 5, it hides form 9 (Question 9) and opens form 5 (Question 5).
  • When I hit PREVIOUS, I want it to hide form 5 (Question 5) and open the last form hidden which is form 9 (Question 9).
  • From Question 9, when I hit PREVIOUS, it hides Question 9 and goes back to Question 1 (Form 1)

Sample visual for the quiz for Form 1 - 10

Would very much appreciate assistance on this. Thanks!

  • The following may be helpful: [Objects and classes in Visual Basic](https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/objects-and-classes/) and [Auto-Implemented Properties (Visual Basic)](https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/procedures/auto-implemented-properties), [Random integer in VB.NET](https://stackoverflow.com/questions/18676/random-integer-in-vb-net). – Tu deschizi eu inchid Nov 10 '22 at 05:39
  • All of the questions can be handled by one form. Use a class which contains the following properties: 1) `Question As String`, 2) `CorrectAnswer As String`, 3) `IncorrectAnswers As List (Of String)`. On the form, change the text for the question and for the possible answers (ie: radio buttons) when a new question should be displayed. Set the `Visible` property for the buttons as appropriate (based on which question is displayed). You may consider using another form to display the summary/results of the quiz. – Tu deschizi eu inchid Nov 10 '22 at 05:44
  • I would go with a single form with a Tab page control. Hide the tabs for the look, then implementing the question navigations is simply just moving either forwards or backwards though the pages collection – Hursey Nov 10 '22 at 19:14

0 Answers0