Lucky 7
Lucky 7 is slot machine, it demastrates how to create random numbers. I also did this in Power Ball.
Add 3 Labels and leave them blank. Add 2 more Buttons, an Image and one more Label.
The first 3 Labels should be the same height and width and should be in squares. One Button should say Spin and one should say Exit.
The last Label should say Lucky 7.
The Image should be of these Coins or something.
Under Command1 (Spin Button) insert the following code:
Private Sub Command1_Click()
Image1.Visible = False
Label1.Caption = Int(Rnd * 10)
Label2.Caption = Int(Rnd * 10)
Label3.Caption = Int(Rnd * 10)
If (Label1.Caption = 7) Or (Label2.Caption = 7) Or
(Label3.Caption = 7) Then
Image1.Visible = True
Beep
End If
End Sub
This is the heart of the program, Image1.Visible = False is there incase you one from the spin before, it clears it. The Labels' Caption = Int(Rnd * 10) creates a random number under 10.
Because the program is called Lucky Seven, you get a jackpot when you get a 7. so the code If (Label1... and so on will check to see if you have a jackpot. It's in ( ) so that it doesn't get confused. The then will give you your jackpot, by displaying coins and beeping.
Insert the following into Command2
Private Sub Command2_Click()
End
End Sub
It ends the program or closes it.
Insert the following under the Form, it keeps the numbers from showing up in certain order. Like the 1st spin is 5 5 9, 2nd
6 9 3, it does randomize but if you close out and start agian you will get the same.
Private Sub Form_Load()
Randomize
End Sub
If you have any problems e-mail me at vbx23@aol.com