CSc430 - Lucky 7 Slot Machine - Programming Steps --
[ Download this | Download coins.wmf ]
Display a stack of coins if a 7 appears in one of the 3 windows
Terminate when End is clicked
File-New Project
Select & place a command button
Add a 2nd command button
Add the number labels
Add the descriptive text label ("Lucky Seven")
Add a picture using the PictureBox control underneath the 3 number labels
Set the properties --
Command1 caption = SPIN
Command2 caption - END
Number label properties -
Select all 3 number labels using Shift key
Click properties button
Set alignment to CENTER
Set BorderStyle to FIXED SINGLE
Set Font to Times New Roman-Bold-24
Release the 3 label windows (click on the form anywhere)
Changle caption property for all 3 labels to NULL (nothing)
Descriptive Label Properties -
Select the descriptive label
Click properties on the toolbar
Change caption to "Lucky Seven"
Change font to Times New Roman-Bold-24
Double click ForeColor propert and set to dark purple
PictureBox Properties
Click on the picturebox object on the form
Click on properties
Double-click the picture property in the properties window
Select the file coins.wmf and click Open
Click the visible property and set to false (picture will be invisible when the program starts)
Writing the code --
Double click END button to open the code window
Type END in the body of the code
Code for the SPIN button
Open the code window for Command1
Here's the code:
Picture1.visible = false 'hide coins
Label1.caption = int(rnd*10) 'pick numbers
Label2.caption = int(rnd*10)
Label3.caption=int(rnd*10)
'
' if any caption is 7, display the coin stack and beep
'
if (label1.caption = 7) or (label2.caption = 7) or (label3.caption = 7) then
picture1.visible = true
beep
end if
Save the program (Save Project As)
Run the program
Create an executable file (Make EXE)
Add to the program - RANDOMIZING to insure different starting random numbers
Select the code window for the FORM_LOAD procedure
Add the statement Randomize to the body of the code
Save new version
Run it