Use a timer and a subprogram to create the animation effect. Besides, you have to add the Multimedia Control to produce the sound effects. To include the multimedia control as one of the tools, click on project on the menu and select components, then click on Microsoft Multimedia Control 6.0. Drag the Multimedia Control into your form and make it invisible at startup. In this program, we use two Multimedia controls, one for playing the spinning sound and the other for the jackpot sound. Below is the interface and the code.
PROPERTY TABLE:
OBJECT
|
PROPERTY
|
VALUE
|
Label1
|
Caption
|
GOOD LUCK
|
Label2
|
Caption
|
YOUR CREDITS
|
Shape1
|
Shape
|
Rounded Rectangle
|
Shape2(0)
|
Shape
|
Rectangle
|
Shape2(1)
|
Shape
|
Rectangle
|
Shape2(2)
|
Shape
|
Rectangle
|
Text1
|
Text
|
Blank
|
Command1
|
Caption
|
Press to Spin
|
Command2
|
Caption
|
Stop
|
PROGRAM:
Dim amount, x, a, b, c As Integer
Private Sub Command1_Click()
Timer1.Enabled = True
MMControl1.Command = "Close"
MMControl2.Command = "close"
x = 0
Label2.Caption = "Your Credits"
amount = Val(Text1)
End Sub
Private Sub Form_Load()
Label1.Caption = " Welcome to Play"
Label3.Visible = False
End Sub
Private Sub instruct_click()
Label3.Visible = True
End Sub
Private Sub Text1_Change()
amount = Val(Text1)
End Sub
Private Sub Timer1_Timer()
If x < 500 Then
spin
Else
Timer1.Enabled = False
MMControl1.Command = "Stop"
Label1.Alignment = 2
If (a = 3 And b = 3 And c <> 3) Or (a = 3 And c = 3 And b <> 3) Or (b = 3 And c = 3 And a <> 3) Then
Label1.Caption = " You win 20 dollars"
amount = amount + 20
End If
If (a = 4 And b = 4 And c <> 4) Or (a = 4 And c = 4 And b <> 4) Or (b = 4 And c = 4 And a <> 4) Then
Label1.Caption = " You win 30 dollars"
amount = amount + 30
End If
If (a = 5 And b = 5 And c <> 5) Or (a = 5 And c = 5 And b <> 5) Or (b = 5 And c = 5 And a <> 5) Then
Label1.Caption = " You win 40 dollars"
amount = amount + 40
End If
If (a = 3 And b = 3 And c = 3) Or (a = 4 And b = 4 And c = 4) Or (a = 5 And b = 5 And c = 5) Then
MMControl2.Notify = False
MMControl2.Wait = True
MMControl2.Shareable = False
MMControl2.DeviceType = "WaveAudio"
MMControl2.FileName = "D:\Liew Folder\VB program\audio\endgame.wav"
MMControl2.Command = "Open"
MMControl2.Command = "Play"
Label1.Caption = " Congratulation! Jackpot!!! You win 200 dollars!"
amount = amount + 200
End If
If (a = 3 And b = 4 And c = 5) Or (a = 3 And b = 5 And c = 4) Or (a = 4 And b = 3 And c = 5) Or (a = 4 And b = 5 And c = 3) Or (a = 5 And b = 4 And c = 3) Or (a = 5 And b = 3 And c = 4) Then
Label1.Caption = " Too bad, you lost 50 dollars"
amount = amount - 50
End If
If amount < 0 Then
Label1.Caption = "Oh! you're bankrupt!"
End If
Text1.Text = Str$(amount)
End If
End Sub
Sub spin()
x = x + 10
Randomize Timer
a = 3 + Int(Rnd * 3)
b = 3 + Int(Rnd * 3)
c = 3 + Int(Rnd * 3)
MMControl1.Notify = False
MMControl1.Wait = True
MMControl1.Shareable = False
MMControl1.DeviceType = "WaveAudio"
MMControl1.FileName = "D:\Liew Folder\VB program\audio\slot2.wav"
MMControl1.Command = "Open"
MMControl1.Command = "Play"
Label1.Caption = "Good Luck!"
Label1.Alignment = a - 3
Shape2(0).Shape = a
If a = 3 Then
Shape2(0).FillColor = &HFF00&
End If
If a = 4 Then
Shape2(0).FillColor = &HFF00FF
End If
If a = 5 Then
Shape2(0).FillColor = &HFF0000
End If
Shape2(1).Shape = b
If b = 3 Then
Shape2(1).FillColor = &HFF00&
End If
If b = 4 Then
Shape2(1).FillColor = &HFF00FF
End If
If b = 5 Then
Shape2(1).FillColor = &HFF0000
End If
Shape2(2).Shape = c
If c = 3 Then
Shape2(2).FillColor = &HFF00&
End If
If c = 4 Then
Shape2(2).FillColor = &HFF00FF
End If
If c = 5 Then
Shape2(2).FillColor = &HFF0000
End If
End Sub
OUTPUT: