Re: Comparing Empty Value types
From: Jay B. Harlow [MVP - Outlook] (Jay_Harlow_MVP_at_msn.com)
Date: 11/17/04
- Next message: S Shulman: "Newline Char in Textbox Control"
- Previous message: Herfried K. Wagner [MVP]: "Re: Comparing Empty Value types"
- In reply to: Cor Ligthert: "Re: Comparing Empty Value types"
- Next in thread: Herfried K. Wagner [MVP]: "Re: Comparing Empty Value types"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 17 Nov 2004 11:10:35 -0600
Cor (& others),
> however I like more evaluating for equality using the = operator than
So do I, however I want to be certain I know what I am actually comparing &
what I am "slicing" off.
If I use Color.ToArgb to compare the colors I loose comparing the names of
the colors.
Further! As I stated last night in VB.NET 2005 you can use the = operator to
compare colors, it will give you the same result as Color.Equals &
Color.op_Equality, not Color.ToArgb.
So if you want your code to be consistent from VB.NET 2002 to VB.NET 2005
what each method actually does is something to be aware of.
I do find it kind of odd that Color does not have a shared Color.Compare
method, but it has an overloaded = operator.
Hope this helps
Jay
"Cor Ligthert" <notmyfirstname@planet.nl> wrote in message
news:%23IeiyJMzEHA.2624@TK2MSFTNGP11.phx.gbl...
> Jay,
>
> It was just an alternative, this one is not real very important for me,
> however I like more evaluating for equality using the = operator than
> evaluating using a methode and with the color that is possible.
>
> But the "Is" in this functions tells it very good, therefore it is not
> really that important for me.
>
> However as I said, just an alternative.
>
> Cor
>
> "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com>
>
>> Cor (& Herfried),
>> As I stated in my initial reply:
>>
>>> See the Color.Equals function in the online help for some important
>>> remarks about using Color.Equals and when you may want to use
>>> Color.ToArgb to compare two colors.
>>
>> If I want to compare what is visible seen I will use Color.ToArgb in
>> other words to compare the Alpha, Red, Green & Blue values.
>>
>> If I want to compare what is literally used I will use Color.Equals or
>> Color.op_Equality, in other words to compare the names of the color or
>> the values for unnamed colors.
>>
>> For example:
>>
>> Dim color1 As Color = Color.Black
>> Dim color2 As Color = Color.FromArgb(0,0,0)
>>
>> Both are visibly Black, however they are not logically the same value. In
>> other words:
>>
>> If color1.Equals(color2) Then
>> ' color1 is the same named color as color2
>> End If
>>
>> If color1.ToArgb() = color2.ToArgb() Then
>> ' color1 & color2 have the same Alpha, Red, Green & Blue values
>> End If
>>
>> Just a thought
>> Jay
>>
>>
>> "Cor Ligthert" <notmyfirstname@planet.nl> wrote in message
>> news:ulhANFIzEHA.2568@TK2MSFTNGP11.phx.gbl...
>>> Dennis,
>>>
>>> As alternative
>>> If mycolor.ToArgb = mycolor.Empty.ToArgb
>>>
>>> End if
>>>
>>> Cor
>>>
>>> "Dennis" <Dennis@discussions.microsoft.com>:
>>>>
>>>> public mycolor as color = color.Empty
>>>>
>>>> I want to check to see if the user has specified a color like;
>>>>
>>>> if mycolor = Color.Empty then.....
>>>> or
>>>> if mycolor is Color.Empty then .......
>>>>
>>>> I get errors saying that = can be used for colors and is can't be used
>>>> with
>>>> value types. I give up...how do I do this. Thanks.
>>>> --
>>>> Dennis in Houston
>>>
>>>
>>
>>
>
>
- Next message: S Shulman: "Newline Char in Textbox Control"
- Previous message: Herfried K. Wagner [MVP]: "Re: Comparing Empty Value types"
- In reply to: Cor Ligthert: "Re: Comparing Empty Value types"
- Next in thread: Herfried K. Wagner [MVP]: "Re: Comparing Empty Value types"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|