Public Class frmMain
Public counter, x, y, z As Integer
Public sort(3) As Integer
Public f, s, w As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
lblBobSlotMachine.Text = "Bob's Slot Machine"
Randomize()
picMoney.Visible = False
counter = 0
'Start Dice
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
x = Int(Rnd() * 7) + 1
If x = 1 Then
picBox1.Image = My.Resources.Bar
ElseIf x = 2 Then
picBox1.Image = My.Resources.Bar2
ElseIf x = 3 Then
picBox1.Image = My.Resources.Bar3
ElseIf x = 4 Then
picBox1.Image = My.Resources.Apple
ElseIf x = 5 Then
picBox1.Image = My.Resources.Cherry
ElseIf x = 6 Then
picBox1.Image = My.Resources.grapes
Else
picBox1.Image = My.Resources.seven
End If
y = Int(Rnd() * 7) + 1
If y = 1 Then
PicBox2.Image = My.Resources.Bar
ElseIf y = 2 Then
PicBox2.Image = My.Resources.Bar2
ElseIf y = 3 Then
PicBox2.Image = My.Resources.Bar3
ElseIf y = 4 Then
PicBox2.Image = My.Resources.Apple
ElseIf y = 5 Then
PicBox2.Image = My.Resources.Cherry
ElseIf y = 6 Then
PicBox2.Image = My.Resources.grapes
Else
PicBox2.Image = My.Resources.seven
End If
z = Int(Rnd() * 7) + 1
If z = 1 Then
PicBox3.Image = My.Resources.Bar
ElseIf z = 2 Then
PicBox3.Image = My.Resources.Bar2
ElseIf z = 3 Then
PicBox3.Image = My.Resources.Bar3
ElseIf z = 4 Then
PicBox3.Image = My.Resources.Apple
ElseIf z = 5 Then
PicBox3.Image = My.Resources.Cherry
ElseIf z = 6 Then
PicBox3.Image = My.Resources.grapes
Else
PicBox3.Image = My.Resources.seven
End If
counter = counter + 1
If counter = 10 Then
Winner()
Timer1.Enabled = False
End If
End Sub
Sub sortItems()
sort(1) = x
sort(2) = y
sort(3) = z
For f = 1 To 3
For s = 1 To 2
If sort(f) < sort(s) Then
w = sort(f)
sort(f) = sort(s)
sort(s) = w
End If
Next s
Next f
x = sort(1)
y = sort(2)
z = sort(3)
End Sub
Sub Winner()
sortItems()
lblTestx.Text = x
lbltesty.Text = y
lblTestz.Text = z
If x = 1 And y = 2 And z = 3 Then
'all bars - all differnt
lblBobSlotMachine.Text = "3 different Bars- $800 Winner"
picMoney.Visible = True
End If
If x = 1 And y = 1 And z = 3 Then
'all bars - all differnt
lblBobSlotMachine.Text = "3 different Bars- $800 Winner"
picMoney.Visible = True
End If
If x = 1 And y = 1 And z = 2 Then
'all bars - all differnt
lblBobSlotMachine.Text = "3 different Bars- $800 Winner"
picMoney.Visible = True
End If
If x = 2 And y = 3 And z = 3 Then
lblBobSlotMachine.Text = "Bars- $800 Winner"
picMoney.Visible = True
End If
If x = 2 And y = 3 And z = 3 Then
lblBobSlotMachine.Text = "Bars- $800 Winner"
picMoney.Visible = True
End If
If x = y And x = z Then
lblBobSlotMachine.Text = "Bars- $800 Winner"
picMoney.Visible = True
End If
If x = y And x = z Then
lblBobSlotMachine.Text = "$800 Winner"
picMoney.Visible = True
End If
If x = 7 And y = 7 And z = 7 Then
lblBobSlotMachine.Text = "$1000 Winner"
picMoney.Visible = True
End If
If x = 5 Or y = 5 Or z = 5 Then
lblBobSlotMachine.Text = "$2 Winner"
picMoney.Visible = True
End If
End Sub
End Class
No comments:
Post a Comment