254 Part II Programming Fundamentals
- In Solution Explorer, click Form1 .vb, click the View Designer button, and then
double-click the Spin button.
The Button1_Click event procedure for the Spin button appears in the Code Editor. - Type the following statements below the Beep() statement in the event procedure:
Wins = Wins + 1
lblWins.Text = "Wins: " & Wins
This part of the program code increments the Wins public variable if a 7 appears
during a spin. The second statement uses the concatenation operator (&) to assign
a string to the lblWins object in the format Wins: X, in which X is the number of wins.
The completed event procedure looks like this:
- Click the Save All button on the Standard toolbar to save all your changes to disk.
Save All saves your module changes as well as the changes on your form and in your
event procedures.
- Click the Start Debugging button to run the program.
- Click the Spin button until you have won a few times.
The Wins label keeps track of your jackpots. Each time you win, it increments the total
by 1. After eight spins, I had the output shown on the following page:
Note The exact number of wins will be different each time you run the program due to
the Randomize statement in the Form1_Load event procedure.