subanki subanki - 11 months ago 60 Question

Unable to use = operator in a "If" statement

Why can't I use = operator over here. Anyway to solve this problem ?

If PictureBox1.Image = My.Resources.pic001 Then
x = 1
x = 0
End If

The error message is:

Operator '=' is not defined for types
'System.Drawing.Image' and


Assuming that PictureBox1.Image references the same Image object as My.Resources.pic001, then you could use:

If Object.ReferenceEquals(PictureBox1.Image, My.Resources.pic001) Then