From: Bob O`Bob on 16 Mar 2010 16:39 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 16 Mar 2010 17:04 "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 16 Mar 2010 17:48 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 16 Mar 2010 20:11 "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 16 Mar 2010 20:20 "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
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Spritley Old Guy Next: Microsoft Excel Object Library missing from IDE |