comparing picturebox image

groover

Member
Joined
Oct 10, 2009
Messages
23
Programming Experience
1-3
I am a beginner with VB and need som help.

I want to check if a picturebox contains a certain image and if it is true give a variable a value.
I have tried the folowing lines of code but no value is returned:

If picturebox1 is ("C:\Users\Documents\Visual Studio 2008\Projects\Image1.jpg") Then Image1value = 1

and

If picturebox1.picture is ("C:\Users\Documents\Visual Studio 2008\Projects\Image1.jpg") Then Image1value = 1

and also

If picturebox1 is Image.FromFile ("C:\Users\Documents\Visual Studio 2008\Projects\Image1.jpg") Then Image1value = 1
and variants.

No errors are generated, but I do not get an integer value for Image1value when Image1.jpg is in the picturebox.

I hope someone can help me with this,

Thanks in advance,


Groover
 
You can use the ImageLocation property or keep the path elsewhere yourself to know what path the image was loaded from. There's no way to read that from an Image object.
 
Thank You for your help.

I have solved the problem with the Tag property by putting the path and the filename in the tag.
I used the following lines:
p1 = Image.FromFile("C:\Users\Documents\Visual Studio 2008\Projects\image1.jpg")
p11 = "C:\Users\Documents\Visual Studio 2008\Projects\image1.jpg"

Picturebox1.Image = p1
Picturebox1.Tag =p11

If Picturebox1.Tag = "C:\Users\Documents\Visual Studio 2008\Projects\image1.jpg" Then
Image1value = 1
It takes a lot of extra coding with many random pictures and 9 Pictureboxes but it works.
It would be easier if the path and filelocation would be the property of the picturebox if a picture is loaded in the picturebox .
I tried to use the ImageLocation property but could not figure it out,

Thanks,

Groover
 
Back
Top