ฉันต้องการสร้างตัวเลขสุ่มระหว่าง 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