Re: Simple? Query the contents of an Imagebox

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Dec 4, 10:38 am, Phillip Taylor <Phillip.Ross.Tay...@xxxxxxxxx>
wrote:
On Dec 4, 10:28 am, Phillip Taylor <Phillip.Ross.Tay...@xxxxxxxxx>
wrote:



On Dec 3, 7:00 pm, "Armin Zingler" <az.nos...@xxxxxxxxxx> wrote:

"Phillip Taylor" <Phillip.Ross.Tay...@xxxxxxxxx> schrieb

On Dec 3, 5:47 pm, "Armin Zingler" <az.nos...@xxxxxxxxxx> wrote:
"Phillip Taylor" <Phillip.Ross.Tay...@xxxxxxxxx> schrieb

I have an image box I set like this:

image1.image = my.resources.yes

or

image1.image = my.resources.no

How can I query which image is in the box later?

Neither

image1.image is my.resources.yes

or

image1.image.equals(my.resources.yes)

work.

Can anybody help?

The generated code is wrong. "Yes" must have been a function, not
a property. A property indicates that each time the same image is
returned. In fact, a new Image is created every time. Therefore,
comparing the image in the Control to the new Image from the
ressource, will always return False.

Remember which image you assigned in a separate variable.

Armin

It's got the property icon. What's more, it's generated
automatically from the properties page for the project. (The
resources tab - each resource gets a name under
My.Resources.<auto_generated>). I
understand what your saying about the references not lining up
because it's not the same instance of the object.

However, it's basically flat out impossible for me to store the
original image description in a seperate variable. This is some of
the most complex code I've written and it's well tested so I can't
afford to change it and get it wrong. I don't want to get into the
symantecs of what the code does or whether it's good coding but
basically I
cannot modify the code in the way you have suggested, which is a
shame.

However, let me explain what I'm trying to do. I have a user control
I wrote myself. When it is disabled, the images within the control
do not change. They still look colourful like this could be clicked
on. What I'm really going for is to have my controls
OnEnabledChanged
value toggle between colourful and "Greyscale" style images but I
cannot compare the image to it's original value. Can anyone help
please?

If you wanted to compare images, you had to compare each pixel. In the Image
property, you will never know where it originally came from. As this
information is not available, you have to remember it anywhere.

Why do you need to know where the image came from? If you want to create a
grayscale image, you can take the image from the Image property.

Armin

I fixed Armin!!!!

I use image1.image.rawformat.equals(my.resources.yes.rawformat)

Thanks for your help dude, that got my cogs turning!

Phill

no. i don't know what I'm talking about. that doesn't work

I've written it myself now. Thanks for the help earlier. The benefit
of everyone this is the code:

Public Function CompareTwoImages(ByRef image1 As Image, ByRef
image2 As Image) As Boolean

If (image1.Height <> image2.Height) Then Return False
If (image1.Width <> image2.Width) Then Return False

'cast to bitmaps so we can have some functionality
Dim img1 As New Bitmap(image1)
Dim img2 As New Bitmap(image2)

'compare every single pixel individually.
For x As Int32 = 0 To img1.Width - 1
For y As Int32 = 0 To img1.Height - 1
If (img1.GetPixel(x, y) <> img2.GetPixel(x, y)) Then
Return False
Next
Next

Return True
End Function
.



Relevant Pages

  • Re: Writing Access functions
    ... Otherwise, create a sub. ... Control sources, Macros (thought the only one you should be using is the ... Public Function NameFromIDAs String ...
    (microsoft.public.access.modulesdaovba)
  • Re: Writing Access functions
    ... passing values by Value or by Reference. ... Public Function NameFromIDAs String ... If you pass a control reference: ...
    (microsoft.public.access.modulesdaovba)
  • Re: Writing Access functions
    ... Public Function NameFromIDAs String ... Dim strName As String ... If you pass a control reference: ...
    (microsoft.public.access.modulesdaovba)
  • RE: Passing form values to module
    ... Do I put this Function in my form code? ... Public Function GetControlText(ByRef ctl As Control) As String ... Public Function GetFormRecordsourceAs String ...
    (microsoft.public.access.modulesdaovba)
  • Re: Which test to use?
    ... 50 rats were made diabetic and compared with 50 ... I would like to compare the ... measurements in each of the 6 regions between the diabetic and control ...
    (sci.stat.math)