subanki subanki - 1 year ago 91 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

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download