What I'm doing is a having scrollbar cycle thru a group of images in a picturebox. Then I have a group of buttons, which change their background image to meet the image displayed in the picture box when they are clicked. In this way the buttons can then form a puzzle. If all the buttons have the right background images, they have solved the puzzle. Which is why I am looking to do an if/then statement to check which image is loaded in each button?
I can also do this with “on click” and load images into pictureboxs instead of buttons. Preloading this image as the background image to button1 does not throw an error, but it likewise does not produce the message box on click.
I can also do this with “on click” and load images into pictureboxs instead of buttons. Preloading this image as the background image to button1 does not throw an error, but it likewise does not produce the message box on click.
Code:
Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Button1.BackgroundImage Is My.Resources.image1 Then
MessageBox.Show("hello")
End If
'or
If Button1.BackgroundImage.Equals(My.Resources.image1) Then
MessageBox.Show("hello")
End If
'or
If Picturebox1.image Is My.Resources.image1 Then
MessageBox.Show("hello")
End If
End Sub
End Class
Comment