System.NullReferenceException: 'Object reference not set to an instance of an object.'

imgArray was Nothing.

This error comes up for my changeimage function for a game i am making. This is the code:


Public Function ChangeIMage(ByVal imgArray() As Image, ByVal imgIncrement As Decimal) As Image
'
imgCounter += imgIncrement

If CInt(imgCounter) > imgArray.GetUpperBound(0) Then
imgCounter = 0
End If

Return imgArray(CInt(imgCounter))
End Function


It was working up until now when i was working on the project. not sure what the error means and how fix it. if i could get an explanation with a solution that would be great. thanks very much in advance.