I wanted to generate a random number between 1 and 20 for a game that I am creating and for some reason this code has stopped working and gives me a type mismatch error, I have tried other generators in the game but I get the same error.
Public Counter1 As Integer ' Counters for each reel
Public ArrayImgMid1 As Integer ' Store number to iterate over image arrays
Public ReelPic1 As Variant ' Array of images for each reel
Public Reel1Spin As Long ' Spins for each reel
Public ImgBeth, ImgWallow, ImgDan, ImgChris, ImgCatBug As StdPicture ' Images for reels
Private Sub CmdSpin_Click()
'Enable all timers to imitate spinning
TimerReel1.Enabled = True
TimerReel1.Interval = 100
' Disable spin button
CmdSpin.Enabled = False
' Set all counters to 0
Counter1 = 0
' Generate random number for the first reel to spin
Reel1Num = (CLng(Rnd * 20) + 1) ' This is highlighted when I press debug