samedi 9 mai 2015

NullReferenceException when loading images in pictureBox vb c#

I'm a beginner on visual basic, and I'm working on this game, it's supposed to load the images that are stored in the picture box array and show them randomly, but I keep getting the runtime error "NullReferenceException" in this line:

 if(egypt[randomNumber]==egypt[0])

The lines before were:

PictureBox [] egypt = new PictureBox [5];
Image egypt1 = Image.FromFile(Application.StartupPath + @"\image\egypt1.png");
egypt[0].Image = egypt1;

Thank you.

Aucun commentaire:

Enregistrer un commentaire