I know that this issue has been treatise many times but I think this time is different. In my Vb program, I have a checkbox and an image. When the user clicks on the checkbox, the visible image becomes invisible and so on. The problem is that I wrote the code but when I compile it, no error occurs, but when I run it a problem tells me "Object reference not set to an instance of an object" saying that the image returns Nothing. The code is very simple
If (DisplayImageCheckBox.IsChecked) Then
NaturePhoto.Visibility = Visibility.Visible
Else
NaturePhoto.Visibility = Visibility.Hidden
End If
The problem is at line 2. The strange thing is that there is no problem about the Else line. If I delete NaturePhoto.Visibility = Visibility.Visible The problem there is not; while if I delete the Else statement and I leave the line after the If one the problem remains. As I said, the NaturePhoto is the photo that disappears and appears, while the DisplayImageCheckBox is the Checkbox to make disappears and not the image. Can you help me, please? I don't know how to solve.