Visal Basic per Begginer

Page 123

104 Visual Basic Programming for the Absolute Beginner

Project: Slot Machine In the slot machine game, you will learn how to build a slot machine using Visual Basic iteration structures and random numbers. You will also learn how to create your own timer using conditions and built-in Visual Basic functions. The game randomizes four images when a user spins the reels. (Well, in this case, he pushes a button.) If the resulting images make up three or four of a kind, points are added to the player’s score. Figure 4.1 showcases the slot machine game.

Been There, Done That So, why loop? Well, iteration or looping is the programmer’s fundamental means of repeating something over and over and over again. Let me show you some obvious and not-so-obvious situations where you might want to create a programmable loop. First are the obvious situations for looping:

• Counting numbers • Reading a file as input until the end-of-file marker is found • Searching through database records • Calculating compound interest • Animating a figure or image

FIGURE 4.1

A slot machine game that randomizes images and tracks the player’s score.


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.