By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,096 Members | 1,355 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,096 IT Pros & Developers. It's quick & easy.

Checking if an image is loaded.

P: 2
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.

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  3.  
  4.         If Button1.BackgroundImage Is My.Resources.image1 Then
  5.             MessageBox.Show("hello")
  6.         End If
  7.         'or
  8.         If Button1.BackgroundImage.Equals(My.Resources.image1) Then
  9.             MessageBox.Show("hello")
  10.         End If
  11.         'or
  12.         If Picturebox1.image Is My.Resources.image1 Then
  13.             MessageBox.Show("hello")
  14.         End If
  15.  
  16.     End Sub
  17. End Class
Apr 4 '07 #1
Share this Question
Share on Google+
3 Replies


vijaydiwakar
100+
P: 579
just leave the image comparision just use its name and compare them or u may link any id with the files and then check them
try it
Good Luck
Apr 4 '07 #2

P: 2
just leave the image comparision just use its name and compare them or u may link any id with the files and then check them
try it
Good Luck
Sorry bro, I really don't understand your reply. The only way I can think to do it is the methods I've shown here. Can you give me an example of what your talking about?
Apr 4 '07 #3

Expert 5K+
P: 8,434
So if I'm reading this correctly, the question is simply how to compare whether two image resources (be they buttons or whatever) in Vb.Net refer to the same image. Right?
Apr 5 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.