In this chapter, you learned how to work with variations of the
Now, before you move on to Chapter 8, "Enhancing Code Structure and Organization," and start learning how to work with procedures, take a few extra minutes and improve the Dice Poker game by completing the following challenges.
Add a menu system to the Dice Poker game, including the following menu items under the File menu: Roll Dice, Roll Again, Stick, and Quit. Also add a Help menu, and provide the player with access to pop-up
Modify the Dice Poker game so that it tracks and displays information about the number of
Enhance the Dice Poker game so that it looks for two of a kind but doesn't add or subtract any dollars from the player's account for this tying hand.
Enhance the Dice Poker game so that it looks to see if the player's hand has two pairs and awards the player a dollar for this winning hand.
Whether you have realized it or not, every application that you have developed so far in this book has relied on procedures to organize and store program code. In this chapter, you will learn how to create your own custom procedures. You will learn how to create
procedures and will understand the difference between the two. You will also learn how to pass data to your procedures for processing and how to return data from
procedures. In addition, you will get plenty of
Specifically, you will learn how to:
Organize the programming logic that makes up your applications into procedures in order to make them easier to develop and maintain
Create custom procedures
Pass and return data to and from procedures
Streamline your applications by placing reusable code within procedures
Develop procedures that can process optional data
In this chapter's project, you will apply your new knowledge of how to work with different types of procedures to the development of the Hangman game. Figures 8.1 to 8.7 show examples from the Hangman game, demonstrating its functionality and overall execution flow.
Figure 8.1: When first started, the game displays a graphic showing an empty hangman's gallows and a series of
Figure 8.2: As the game progresses, each correct guess is displayed at the top of the window, and a visual record of every letter guessed is displayed at the bottom of the window.
Figure 8.3: The game
Figure 8.4: The game only
Figure 8.5: The game prevents the player from entering numeric input.
Figure 8.6: The game congratulates the player when the secret word has been successfully guessed.
Figure 8.7: If the player fails to guess the secret word within six guesses, the game is lost and the picture of the hangman's gallows is updated to show a full hangman image.
By the time you have created and run this game, you will have demonstrated your under standing of how to create custom Sub and Function procedures and how to use them to improve the overall organization and maintenance of your Visual Basic applications.