Digital Slot Machine



This is another simple VB program which is a digital slot machine, it is designed and created by my 10 years old son. In this program, you need to insert three labels for displaying the digits, one label to display the "Slot Machine " name, two command buttons which is used for spinning and ending the program. Lastly, add one image and make it invisible at runtime.

In the program, RND function is used to generate numbers from 1 to 9 using the formula Int(Rnd * 10) so that the numbers appear randomly on the three labels. Whenever any one digit 7 appear, the image will be made visible and you may make the program play a sound using MMControl.

The codes are as follows:

Private Sub Command1_Click()
MMControl1.Command = "Close"
Randomize Timer
Picture1.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
Picture1.Visible = True
MMControl1.Notify = False
MMControl1.Wait = True
MMControl1.Shareable = False
MMControl1.DeviceType = "WaveAudio"
MMControl1.FileName = "D:\Liew Folder\VB program\audio\applause.wav"
MMControl1.Command = "Open"
MMControl1.Command = "Play"
End If
End Sub

Private Sub Command2_Click()
End Sub

Private Sub Form_Click()
Label5.Visible = False

End Sub

Private Sub help_Click()
Label5.Visible = True

End Sub




[Back to Game Page]