Tutorial 2: Create a Timed Math Quiz
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Tutorial 2: Create a Timed Math Quiz.
In this tutorial, you build a quiz in which the quiz taker must answer four random arithmetic problems within a specified time. You learn how to:
Generate random numbers by using the
Randomclass.Trigger events to occur at a specific time by using a Timer control.
Control program flow by using
if elsestatements.Perform basic arithmetic operations in code.
When you finish, your quiz will look like the following picture, except with different numbers.

Quiz that you create in this tutorial
To download a completed version of the quiz, see Complete Math Quiz tutorial sample.
This tutorial covers both Visual C# and Visual Basic, so focus on the information that's specific to the programming language that you're using. |
| Title | Description |
|---|---|
| Step 1: Create a Project and Add Labels to Your Form | Start by creating the project, changing properties, and adding Label controls. |
| Step 2: Create a Random Addition Problem | Create an addition problem, and use the Random class to generate random numbers. |
| Step 3: Add a Countdown Timer | Add a countdown timer so that the quiz can be timed. |
| Step 4: Add the CheckTheAnswer() Method | Add a method to check whether the quiz taker entered a correct answer for the problem. |
| Step 5: Add Enter Event Handlers for the NumericUpDown Controls | Add event handlers that make your quiz easier to take. |
| Step 6: Add a Subtraction Problem | Add a subtraction problem that generates random numbers, uses the timer, and checks for correct answers. |
| Step 7: Add Multiplication and Division Problems | Add multiplication and division problems that generate random numbers, use the timer, and check for correct answers. |
| Step 8: Customize the Quiz | Try other features, such as changing colors and adding a hint. |