From: Bob O`Bob on
Henning wrote:
> "Nobody" <nobody(a)nobody.com> skrev i meddelandet
> news:O35gNDQxKHA.1548(a)TK2MSFTNGP02.phx.gbl...
>> "Henning" <computer_hero(a)coldmail.com> wrote in message
>> news:edXiI$PxKHA.3564(a)TK2MSFTNGP05.phx.gbl...
>>> You can test using:
>>> If (struct.flags And LLKHF_INJECTED) > 0 Then 'An injected key
>>>
>>> /Henning
>> It's preferable to use "<> 0" or "= 0". If the flag was &H80000000, which
>> is a negative number, the result would be negative in the above statement.
>>
>>
>
> In general thats correct, I was not concidering values other than presented.
>
> /Henning
>
>


Personally, I prefer the *implied* "<> 0" that you get from simply coding

If (struct.flags And LLKHF_INJECTED) Then 'An injected key

Don't know if it's any faster, but I'm positive that it's not slower.


Bob
--
From: Nobody on
"Bob O`Bob" <filterbob(a)yahoogroups.com> wrote in message
news:%23IXWKjUxKHA.1548(a)TK2MSFTNGP02.phx.gbl...
> Henning wrote:
>> "Nobody" <nobody(a)nobody.com> skrev i meddelandet
>> news:O35gNDQxKHA.1548(a)TK2MSFTNGP02.phx.gbl...
>>> "Henning" <computer_hero(a)coldmail.com> wrote in message
>>> news:edXiI$PxKHA.3564(a)TK2MSFTNGP05.phx.gbl...
>>>> You can test using:
>>>> If (struct.flags And LLKHF_INJECTED) > 0 Then 'An injected key
>>>>
>>>> /Henning
>>> It's preferable to use "<> 0" or "= 0". If the flag was &H80000000,
>>> which is a negative number, the result would be negative in the above
>>> statement.
>>>
>>>
>>
>> In general thats correct, I was not concidering values other than
>> presented.
>>
>> /Henning
>>
>>
>
>
> Personally, I prefer the *implied* "<> 0" that you get from simply coding
>
> If (struct.flags And LLKHF_INJECTED) Then 'An injected key
>
> Don't know if it's any faster, but I'm positive that it's not slower.

The problem with not using something like "<> 0" is that the result could be
other than 0 or -1, so if you later add more conditions, and forgot that VB
always does bitwise operations, you get unexpected result.


From: Karl E. Peterson on
Nobody wrote:
> "Bob O`Bob" <filterbob(a)yahoogroups.com> wrote...
>> Personally, I prefer the *implied* "<> 0" that you get from simply coding
>>
>> If (struct.flags And LLKHF_INJECTED) Then 'An injected key
>>
>> Don't know if it's any faster, but I'm positive that it's not slower.
>
> The problem with not using something like "<> 0" is that the result could be
> other than 0 or -1, so if you later add more conditions, and forgot that VB
> always does bitwise operations, you get unexpected result.

Ahh, but that would be a *personal* problem, not one with the language.
;-)

--
..NET: It's About Trust!
http://vfred.mvps.org


From: Henning on

"Nobody" <nobody(a)nobody.com> skrev i meddelandet
news:uaY2$wUxKHA.3564(a)TK2MSFTNGP05.phx.gbl...
> "Bob O`Bob" <filterbob(a)yahoogroups.com> wrote in message
> news:%23IXWKjUxKHA.1548(a)TK2MSFTNGP02.phx.gbl...
>> Henning wrote:
>>> "Nobody" <nobody(a)nobody.com> skrev i meddelandet
>>> news:O35gNDQxKHA.1548(a)TK2MSFTNGP02.phx.gbl...
>>>> "Henning" <computer_hero(a)coldmail.com> wrote in message
>>>> news:edXiI$PxKHA.3564(a)TK2MSFTNGP05.phx.gbl...
>>>>> You can test using:
>>>>> If (struct.flags And LLKHF_INJECTED) > 0 Then 'An injected key
>>>>>
>>>>> /Henning
>>>> It's preferable to use "<> 0" or "= 0". If the flag was &H80000000,
>>>> which is a negative number, the result would be negative in the above
>>>> statement.
>>>>
>>>>
>>>
>>> In general thats correct, I was not concidering values other than
>>> presented.
>>>
>>> /Henning
>>>
>>>
>>
>>
>> Personally, I prefer the *implied* "<> 0" that you get from simply coding
>>
>> If (struct.flags And LLKHF_INJECTED) Then 'An injected key
>>
>> Don't know if it's any faster, but I'm positive that it's not slower.
>
> The problem with not using something like "<> 0" is that the result could
> be other than 0 or -1, so if you later add more conditions, and forgot
> that VB always does bitwise operations, you get unexpected result.
>
>

Actually, yes, (struct.flags And LLKHF_INJECTED) will be &H10 (16) if that
bit is a one.

/Henning


From: Henning on

"Nobody" <nobody(a)nobody.com> skrev i meddelandet
news:uaY2$wUxKHA.3564(a)TK2MSFTNGP05.phx.gbl...
> "Bob O`Bob" <filterbob(a)yahoogroups.com> wrote in message
> news:%23IXWKjUxKHA.1548(a)TK2MSFTNGP02.phx.gbl...
>> Henning wrote:
>>> "Nobody" <nobody(a)nobody.com> skrev i meddelandet
>>> news:O35gNDQxKHA.1548(a)TK2MSFTNGP02.phx.gbl...
>>>> "Henning" <computer_hero(a)coldmail.com> wrote in message
>>>> news:edXiI$PxKHA.3564(a)TK2MSFTNGP05.phx.gbl...
>>>>> You can test using:
>>>>> If (struct.flags And LLKHF_INJECTED) > 0 Then 'An injected key
>>>>>
>>>>> /Henning
>>>> It's preferable to use "<> 0" or "= 0". If the flag was &H80000000,
>>>> which is a negative number, the result would be negative in the above
>>>> statement.
>>>>
>>>>
>>>
>>> In general thats correct, I was not concidering values other than
>>> presented.
>>>
>>> /Henning
>>>
>>>
>>
>>
>> Personally, I prefer the *implied* "<> 0" that you get from simply coding
>>
>> If (struct.flags And LLKHF_INJECTED) Then 'An injected key
>>
>> Don't know if it's any faster, but I'm positive that it's not slower.
>
> The problem with not using something like "<> 0" is that the result could
> be other than 0 or -1, so if you later add more conditions, and forgot
> that VB always does bitwise operations, you get unexpected result.
>
>

Hitting send to early...

This could also be written as If (struct.flags And LLKHF_INJECTED) =
LLKHF_INJECTED Then.

/Henning