PDA

Click to See Complete Forum and Search --> : .BackColor Comparison?


pres201
Jun 10th, 2002, 07:38 PM
Hey all....

If someone comes up with the answer to this quick, I'd like to know how to search for strange problems like this in the MSDN...:)

A simple comparison operation. I want to perform a certain operation if a label's BackColor property is set to a certain color, ie. Color.Transparent. So logically I do the following:

label.BackColor = Color.Transparent

'.... some code ....

If (label.BackColor = Color.Transparent) Then
'...
End If

But I get an error stating that the '=' operator isn't defined by System.Drawing.Colors. This isn't making much sense. Not too sure how I can get the logic to work without some dumb workarounds if I can't compare colors. Anyone?

Regards,
Brian

Kevin_0011
Jun 10th, 2002, 08:08 PM
Just curious, why are you comparing a number in RGB format (or hexadecimal format depending of the control) with a boolean variable.

Anyways, that has happened to me too, except under more normal circumstances ;) Weird.....

Zaei
Jun 10th, 2002, 08:27 PM
An RGB Color value is a Long Value. A Hexidecimal value is simply a way of representing a number. They are both the same. In the case of colors, The hex value is easier to read.

Z.

pres201
Jun 10th, 2002, 10:03 PM
Color.Transparent isn't a Boolean variable.... as I showed in the code, you can set the Transparent 'color' (system-defined), but you can't compare it after to see if that color took effect.

There must be some way of comparing the value of .BackColor....

Brian

pres201
Jun 10th, 2002, 10:05 PM
This is being done in VB.NET by the way... odd that I forgot to mention that before. I had no problems with this sort of operation in VB 6, but I'm aware things are a lot different in this situation.

Brian