S
SimonGru
Guest
So right now, I'm making a game and I'm using arrays to make things easier to code. However, after beating my game form "Heart", I get an error in a completely different form "Liver" saying "Object reference not set to an instance of an object." However, when I load my game from form "Liver", it works perfectly fine until i beat the game, in which case the code in "Heart" breaks. I have no idea what's going on
Public Class Liver
Private enemy1(5) As PictureBox
Private Sub Liver_Load(sender As Object, e As EventArgs) Handles Me.Load
Me.CenterToScreen()
enemy1(0) = picEnemy1
enemy1(1) = picEnemy2
enemy1(2) = picEnemy3
enemy1(3) = picEnemy4
enemy1(4) = picEnemy5
Private Sub tmrMove_Tick(sender As Object, e As EventArgs) Handles tmrMove.Tick
Dim i As Integer
For i = 0 To 4
If isup = True Then
enemy1(i).Location = New Point(enemy1(i).Location.X, enemy1(i).Location.Y - rate)
End If
Next
The code here stops working at
enemy1(i).Location = New Point(enemy1(i).Location.X, enemy1(i).Location.Y - rate)
The error is enemy1() was nothing
Any help would be appreciated
Continue reading...
Public Class Liver
Private enemy1(5) As PictureBox
Private Sub Liver_Load(sender As Object, e As EventArgs) Handles Me.Load
Me.CenterToScreen()
enemy1(0) = picEnemy1
enemy1(1) = picEnemy2
enemy1(2) = picEnemy3
enemy1(3) = picEnemy4
enemy1(4) = picEnemy5
Private Sub tmrMove_Tick(sender As Object, e As EventArgs) Handles tmrMove.Tick
Dim i As Integer
For i = 0 To 4
If isup = True Then
enemy1(i).Location = New Point(enemy1(i).Location.X, enemy1(i).Location.Y - rate)
End If
Next
The code here stops working at
enemy1(i).Location = New Point(enemy1(i).Location.X, enemy1(i).Location.Y - rate)
The error is enemy1() was nothing
Any help would be appreciated
Continue reading...