我想創建一個簡單的遊戲,首先它需要隨機加載16個圖片框與圖像。我不確定問題出在哪裏。試圖分配圖片到VB中的圖片框
Public Class Form1
Private picArrows() As PictureBox = {pic11, pic12, pic13, pic14,
pic21, pic22, pic23, pic24,
pic31, pic32, pic33, pic34,
pic41, pic42, pic43, pic44}
Private Sub btnNew_Click(sender As Object, e As EventArgs) Handles btnNew.Click
'starts a new game
'declares RNG
Dim randGen As New Random
'uses RNG to determine arrow placement
For intPicBox As Integer = 0 To 15
Select Case randGen.Next(1, 5)
Case 1
picArrows(intPicBox).Image = My.Resources.Up
Case 2
picArrows(intPicBox).Image = My.Resources.Right
Case 3
picArrows(intPicBox).Image = My.Resources.Down
Case 4
picArrows(intPicBox).Image = My.Resources.Left
End Select
Next
End Sub
End Class
我上線一個NullReferenceException錯誤之後案例X任何人都知道我做錯了嗎?
你沒有說什麼不順心或者我得到一個什麼樣的錯誤是 – Plutonix 2015-03-31 22:15:40
在案例X之後的行上的NullReferenceException錯誤 – ShinigamiMachine 2015-03-31 22:33:38
可能重複[什麼是NullReferenceException,我該如何解決它?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how- do-i-fix-it) – Plutonix 2015-03-31 22:36:33