Checking if an image is loaded.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jrtiberius
    New Member
    • Apr 2007
    • 2

    Checking if an image is loaded.

    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.

    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
    Last edited by Killer42; Apr 5 '07, 03:04 AM. Reason: Please use [CODE]...[/CODE] tags around your code.
  • vijaydiwakar
    Contributor
    • Feb 2007
    • 579

    #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

    Comment

    • jrtiberius
      New Member
      • Apr 2007
      • 2

      #3
      Originally posted by vijaydiwakar
      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?

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        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?

        Comment

        Working...