我想为我正在创建的游戏生成一个介于 1 和 20 之间的随机数,由于某种原因,此代码停止工作并给我一个类型不匹配错误,我在游戏中尝试了其他生成器,但我得到了同样的错误。
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