VB2019 VB2017 VB2015 VB2013 VB2012 VB2010 VB2008 VB6 VB Sample Codes 中文VB About Us

Digital Slot Machine



This is a digital slot machine created by us using VB6. 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. We use the Rnd function to generate random numbers from 0 to 9 using the formula Int(Rnd * 10) that will be displayed on the three labels. Whenever a 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"
 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 


 


Copyright©2008 Dr.Liew Voon Kiong. All rights reserved |Contact|Privacy Policy