CHAPTER 6 MAKING DECISIONS WITH CONDITIONAL LOGIC (Email web hosting)

CHAPTER 6 MAKING DECISIONS WITH CONDITIONAL LOGIC 183 If sdrControl.Value < intSecretNumber Then 'See if the player's guess was low edfAnalysis.Text = "Too Low!" 'Update game status End If If sdrControl.Value > intSecretNumber Then ‘See if the player’s guess was high edfAnalysis.Text = “Too High!” ‘Update game status End If ‘Do not update the display of the Slider control’s value when it is zero If sdrControl.Value <> 0 Then ‘Display the Slider control’s value as the player moves the its handle edfDisplay.Text = Cstr(sdrControl.Value) End If Note A subroutine is a collection of programming statements that can be called and executed as a unit. Subroutines are sometimes referred to as procedures. This subroutine is called whenever the player moves and releases the Slider control s handle. It begins by incrementing the value of intNoGuessedby 1, and then displays its value in the appropriate EditField, after converting its value to a string data type. Three If Then blocks are then set up, each of which tests for a different condition. The first If Then block executes when the player correctly guesses the game s secret number (for example, when sdrControl.Valueis equal to intSecretNumber). When this occurs, a series of code statements are executed that update the information displayed in the GroupBox control. In addition, the Slider control is disabled to stop game play and the PushButton labeled Play is enabled, allowing the player to start a new game. The second If Then block executes when the value specified by the player is less than the game s secret number. Similarly, the third If Then block executes when the value specified by the player is higher than the secret number. In both of these cases, a text string is displayed in the EditField control labeled Analysis to provide the player with a clue that guides her next guess.
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

Leave a Reply