1

So, I have an array of picture boxes

Dim LocationArray(8,6) As PictureBox

I have set the array to pictures boxes as so

ArrayLocation(0,0)=pic00
ArrayLocation(0,1)=pic01

ect.

So, when the form loads, I want the picture box (3,0) to load with a picture in it

So far I have

LocationArray(3,0).Image = My.Recources.pic

And nothing happens when I load the form.

When I try to display a picture after changing which the coordinates of the array, I get a NullreferenceExepecation error. How will I be able to fix this, the code I have so far is,

 Static xAxis As Integer = 3
    Static yAxis As Integer = 0
    LocationArray(xAxis, yAxis).Visible = False
    xAxis = +1
    LocationArray(xAxis, yAxis).Image = My.Resources.man
    LocationArray(yAxis, xAxis).Visible = True
  • What event are you using to run this code? – Idle_Mind Dec 13 '13 at 05:18
  • For LocationArray(3,0).Image = My.Recources.pic I am using Form Load And I am using a Button Click when trying to change the coordinates – user3097757 Dec 13 '13 at 05:28
  • In some places you have "LocationArray" and others you have "ArrayLocation". Also, in the bottom two lines, you've swapped the position of the "xAxis" and "yAxis" variables in the last line? – Idle_Mind Dec 13 '13 at 05:50
  • You increment wrong. `xAxis = +1` is like saying _xAxis_ equals a positive number of 5. You should user the `+=` operator. – Bjørn-Roger Kringsjå Dec 13 '13 at 07:40
  • Duplicate of [What is a NullReferenceException and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Bjørn-Roger Kringsjå Nov 19 '15 at 05:31

0 Answers0