Digital Slot Machine

[Back  to Sample VB Codes]

This is a simple digital slot created by us using Visual Basic. 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. Besides that, you may want to make the program plays a sound using MMControl.

The Interface

The Code

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
End Sub

Private Sub Form_Click()
Label5.Visible = False


End Sub

Private Sub help_Click()
Label5.Visible = True


End Sub

[Back  to Sample VB Codes]

Copyright ® 2008 Dr.Liew Voon Kiong . All rights reserved |Contact

[Privacy Policy]