| Chapter 3- Data Types and Operators | Boolean Expressions Page 2 3 4 |
| The If Statement Page 2 3 4 5 6 7 8 9 | |
| Arithmetic Operations Page 2 3 4 5 6 | Boolean Operators and Nested If Statements Page 2 3 4 5 6 7 |
| Events and Sequential Processing Page 2 3 4 5 | More Examples Page 2 3 4 5 6 7 8 9 10 11 12 |
| Datatypes and Conversions Page 2 3 4 5 6 7 | Using Check Box and Option Controls Page 2 3 4 5 6 7 8 9 10 |
| Variable Declarations - Local and Global Page 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Exercises Page 2 3 4 5 6 7 8 |
| Chapter 4- Selection Statements | Review Questions |
| Introduction | |
4-3: If Statements
Exercise 4-2: Number Guessing Game (continued ...)
Now that we know the statements necessary to generate a random integer we need to decide where these statements should appear in our program. Where should the variables, i.e. the object variable randomNum and the Integer variable numToGuess be declared? And where should the statement that assigns a value to numToGuess be placed?
When the program is first started a random value must be calculated. This suggests that we need to program the New event of the form object to contain the assignment statement previously. But should the randomNum object variable and the numToGuess Integer variable be declared locally or globally?
If you haven't already done so, start Visual Basic, create the interface (specifying object names txtGuess, btnCheckIt, lblMessage, btnPlayAgain and btnExit), and go ahead and create the New event code and the variable declarations.
Next, the Play again button should