8 Replies - 2092 Views - Last Post: 19 November 2012 - 02:00 PM Rate Topic: -----

#1 BJseal91  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 68
  • Joined: 18-April 09

Operator '=' is not defined for types 'System.Drawing.Imag

Posted 19 November 2012 - 01:34 AM

Programmers,
can anyone help with a problem I am faced with,

http://i877.photobuc...91/Untitled.png

above is the picture of a program I am building, and am faced with an error

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

Objective;

to click the flag button and it adds a flag image to the button, as you can see no problem doing this but when I add the code to remove it, it comes up with the error above

Button2.Image = My.Resources.mark And Button2.Image = Nothing


additional information

the 2nd part of the code
Button2.Image = Nothing
works on on its own as well but if you put the 2 together in the same line you get a debug error

how can I solve this problem

Kind Regards

Bradley

Is This A Good Question/Topic? 0
  • +

Replies To: Operator '=' is not defined for types 'System.Drawing.Imag

#2 raghav.naganathan  Icon User is offline

  • Perfectly Squared ;)
  • member icon

Reputation: 408
  • View blog
  • Posts: 1,440
  • Joined: 14-September 12

Re: Operator '=' is not defined for types 'System.Drawing.Imag

Posted 19 November 2012 - 02:25 AM

I am not sure if this is correct, but since the AND operator returns true only if both conditions are true, you seem to be getting that error.

I have a question. Why would you want to use both of them in the same line?

regards,
Raghav
Was This Post Helpful? 0
  • +
  • -

#3 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Operator '=' is not defined for types 'System.Drawing.Imag

Posted 19 November 2012 - 02:51 AM

Please, try to explain what exactly would you like to achieve with:
Button2.Image = My.Resources.mark And Button2.Image = Nothing
Was This Post Helpful? 0
  • +
  • -

#4 biggerB  Icon User is offline

  • If at first you donít succeed, call it version 1.0
  • member icon

Reputation: 80
  • View blog
  • Posts: 760
  • Joined: 11-June 10

Re: Operator '=' is not defined for types 'System.Drawing.Imag

Posted 19 November 2012 - 07:33 AM

The And is not the right thing to use when you want to add multiple statements on the same line of code, use the Colon (:) to separate the two statements. So the line would become Button2.Image = My.Resources.mark : Button2.Image = Nothing
Was This Post Helpful? 0
  • +
  • -

#5 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Operator '=' is not defined for types 'System.Drawing.Imag

Posted 19 November 2012 - 07:50 AM

:)/> yeah biggerB, you are right, but I was wondering why would anyone want to set background image of the button to some image from resources, and "instantly" set background image for the same button to nothing?!
Was This Post Helpful? 0
  • +
  • -

#6 biggerB  Icon User is offline

  • If at first you donít succeed, call it version 1.0
  • member icon

Reputation: 80
  • View blog
  • Posts: 760
  • Joined: 11-June 10

Re: Operator '=' is not defined for types 'System.Drawing.Imag

Posted 19 November 2012 - 07:56 AM

lucky3 Beats me.. But thats all i see wrong with the code.. :P
Was This Post Helpful? 0
  • +
  • -

#7 BJseal91  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 68
  • Joined: 18-April 09

Re: Operator '=' is not defined for types 'System.Drawing.Imag

Posted 19 November 2012 - 11:52 AM

Thank you for your replies,
As you saw by the picture I uploaded for view it is a question and answer program and with the option to flag questions and it come up with a flag.
The reason behind the code is that you can do the same with a picture box so you would say picture box 1.visable = true and picture box1.visable = false you when the flag button is pressed once it will display a flag and if pressed again it will remove the flag so they can add and remove flags to the questions.
What I am looking for is a code that will display and de display the flag on each button

Kind Regards
Was This Post Helpful? 0
  • +
  • -

#8 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Operator '=' is not defined for types 'System.Drawing.Imag

Posted 19 November 2012 - 12:04 PM

So you wanna switch flag on and off as a button image? On button click event handler do something like this then:
        If IsNothing(Button2.Image) Then
            Button2.Image = My.Resources.mark
        Else
            Button2.Image = Nothing
        End If


Was This Post Helpful? 1
  • +
  • -

#9 BJseal91  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 68
  • Joined: 18-April 09

Re: Operator '=' is not defined for types 'System.Drawing.Imag

Posted 19 November 2012 - 02:00 PM

View Postlucky3, on 19 November 2012 - 12:04 PM, said:

So you wanna switch flag on and off as a button image? On button click event handler do something like this then:
        If IsNothing(Button2.Image) Then
            Button2.Image = My.Resources.mark
        Else
            Button2.Image = Nothing
        End If



Yes that was perfect and what I was trying to Achive thank you very much for your help

Problem Solved

Kind Regards

Bradley Scott
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1