PDA

View Full Version : Help switching between two images



Goodicore
04-16-2015, 03:49 AM
Hi, I need some help on a picture box and switching between 2 images

I have added to images to my resources and I want to switch between the 2 images once clicking on them

I have the below code and when I click it changes the image but how can I hange back to original when I click again?

Private
Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click

PictureBox1.Image =
My.Resources.Mario


End Sub

End
Class

sjeter
04-25-2015, 11:56 AM
Need to use an If Else statement. When you click the picture box, if it already shows Mario, then set picturebox equal to the other image. Replace the ?? with name of the other picture file.

If PictureBox1.Image = My.Resources.Mario Then
PictureBox1.Image = My.Resources.??
Else
PictureBox1.Image = My.Resources.Mario
End If