Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Guess My Number Game Figure 1 Instructions In this case, you will create a Visual Basic solution that plays a number guessing game with the

Guess My Number Game

Figure 1

image text in transcribed

Instructions In this case, you will create a Visual Basic solution that plays a number guessing game with the user. The program will randomly generate a value between one and ten, and will compare the users guess to this value. The program will give the user five attempts to guess the correct number. When the user exits the game, the program will display the percentage of guesses that were correct. This program uses counters and accumulators.

Step 1: Create the Project: Create a Visual Basic Project using the project name GuessMyNumber.

Step 2 Design the Form: Design the form as shown in Figure 1. You will need three button controls, one text box, and two label controls. Set the Check My Guess button to be the AcceptButton on the form.

Step 3 Declare required variables: You will need to declare four variables to be used as follows: 1. An integer counter variable for the guess limit. 2. An integer accumulator variable to accumulate the number of correct guesses. 3. An integer accumulator variable to accumulate the total number of guesses. 4. An integer variable to store the randomly generated answer value Because these variables must hold their value throughout the time the program is running, declare them as module-level variables in the Forms Declarations area.

Step 4 Add code in the Forms Load event to generate an initial random value: In the Forms Load event, write code to initialize the random object and to generate a random number between 1 and 10. Store the generated number in the answer variable declared above.

Step 5 Add code in the Check My Guess buttons Click event to validate the user input: Use the TryParse method to validate that the user entered a numeric value for the guess. If the textbox value is not numeric, display a message box explaining the error, then put the focus into the textbox with the error. Use the Exit Sub statement to leave the Click event if there was an error.

Your validation code for score textboxes should be in this form:

image text in transcribed

Please List what the labels, buttons, text box, etc.. are coded as for example checkButton and exitButton

Guess My Number I'm thinking of a number between 1 and 10. Enter your guess and click on the Check My Guess button. Your guess: Check My Guess Start a New Game Exit Guess My Number I'm thinking of a number between 1 and 10. Enter your guess and click on the Check My Guess button. Your guess: Check My Guess Start a New Game Exit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

2. Outline the business case for a diverse workforce.

Answered: 1 week ago