I am currently working on a project in VB and I am having 2 issues, both in the btnPull_Click function.
First is having the 3 wheels mimic the spin of the slot machine. I have the .sleep in there for the delay you would see but I can't seem to get it to flash other images up before finally stopping. I don't think this is a requirement for the project, but I would like to know how to do this.
The MAIN issue I am having is with my if/then statement. I have my arrays(project requirement), but the problem I am running into is that I can't convert an image to a string. I was trying to set NumOfSpins(1,2,3) equal to the Slots(INDEX) and determine from there the value of the payout.
I tried taking my For statement and creating a private function, but I could not get that to work either. I guess I am just really stuck and would appreciate any advice I can get.
Const Slot_Size As Integer = 7
Dim Slots() As Image = {My.Resources.Slot_Cherry, My.Resources.Slot_7, My.Resources.Slot_Bar, My.Resources.Slot_Bell, My.Resources.Slot_Grapes, My.Resources.Slot_Lemon, My.Resources.Slot_Orange}
Dim slotImages() As String = {"cherry", "seven", "bar", "bell", "grapes", "lemon", "orange"}
Dim slotOrder() As Integer = {1, 2, 3}
Private Function RandomNumber(ByVal low As Integer, ByVal high As Integer)
Randomize()
Return Convert.ToInt32(((high - low) * Rnd() + low))
End Function
Private Sub Clear()
For counter = 0 To Slot_Size - 1 Step 1
Slots(counter) = My.Resources.Slot_Bar
Next
End Sub
Private Sub btnPull_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPull.Click
'Spins the 3 slot wheels
Dim NumOfSpins1 As Integer = RandomNumber(Slot_Size * 5, Slot_Size * 10)
Dim NumOfSpins2 As Integer = RandomNumber(Slot_Size * 5, Slot_Size * 10)
Dim NumOfSpins3 As Integer = RandomNumber(Slot_Size * 5, Slot_Size * 10)
lblBalance.Text = "$" & balance
For spin = 0 To NumOfSpins1 Step 1
Slot1.Image = Slots(spin Mod Slot_Size)
Next
For spin = 0 To NumOfSpins2 Step 1
Slot2.Image = Slots(spin Mod Slot_Size)
Next
For spin = 0 To NumOfSpins3 Step 1
Slot3.Image = Slots(spin Mod Slot_Size)
Next
Return
System.Threading.Thread.Sleep(100)
Slot1.Refresh()
Slot2.Refresh()
Slot3.Refresh()
'Determine if the user wins or loses money
If NumOfSpins1 = slotImages(0) Then
balance += 2
End If
End Sub
End Class