From: Mayayana on
| Yes I will be the first to admit that i do not have any knowledge on bit
| operations but so far this has not stopped me from getting useful code to
| work to my requirements. I have read the article that Kevin Provance
| suggested at that has not helped me to understand the problem I have.
| As you said I had tried the prints to the intermediate window and I get
this
| result
|
| ? (17 and 16) <> 16 Result False
| ? (16 and 16) <> 16 Result False
| is this the correct answer? it seem from what you said it is. OK
|

Since it's a bit flag you're comparing bit values. It's
misleading because "And" doesn't make sense
until you know that. The values in binary are:

16: 00010000
17: 00010001

So 17 And 16 = 16 because that is the sum of the shared
bits. By doing x And 16 you can check whether the 16 bit is
set. It doesn't matter which other bits are or are not set. "And"
is just a simple masking device. (If that doesn't make sense
you might want to look up how decimal/hex/binary values
express numbers and how that relates to bits.



From: LondonLad on
Hi Mayayana
Thank for your very clear explanation what would be the bit answer that is
equal and allow code within the if statement to function.

'if the object is not a folder
If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <>
FILE_ATTRIBUTE_DIRECTORY Then

other code

End if

I thought that the author was making sure that it was a folder its seems to
me that when it is a folder it still does not become equal and therefore does
not satisfy the question.

I would appreciate further help if you can.

"Mayayana" wrote:

> | Yes I will be the first to admit that i do not have any knowledge on bit
> | operations but so far this has not stopped me from getting useful code to
> | work to my requirements. I have read the article that Kevin Provance
> | suggested at that has not helped me to understand the problem I have.
> | As you said I had tried the prints to the intermediate window and I get
> this
> | result
> |
> | ? (17 and 16) <> 16 Result False
> | ? (16 and 16) <> 16 Result False
> | is this the correct answer? it seem from what you said it is. OK
> |
>
> Since it's a bit flag you're comparing bit values. It's
> misleading because "And" doesn't make sense
> until you know that. The values in binary are:
>
> 16: 00010000
> 17: 00010001
>
> So 17 And 16 = 16 because that is the sum of the shared
> bits. By doing x And 16 you can check whether the 16 bit is
> set. It doesn't matter which other bits are or are not set. "And"
> is just a simple masking device. (If that doesn't make sense
> you might want to look up how decimal/hex/binary values
> express numbers and how that relates to bits.
>
>
>
> .
>
From: Henning on
OBS! 'if the object is *not* a folder

/Henning

"LondonLad" <LondonLad(a)discussions.microsoft.com> skrev i meddelandet
news:68992D5B-C45F-47AF-9497-C7BE19587CB1(a)microsoft.com...
> Hi Mayayana
> Thank for your very clear explanation what would be the bit answer that is
> equal and allow code within the if statement to function.
>
> 'if the object is not a folder
> If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <>
> FILE_ATTRIBUTE_DIRECTORY Then
>
> other code
>
> End if
>
> I thought that the author was making sure that it was a folder its seems
> to
> me that when it is a folder it still does not become equal and therefore
> does
> not satisfy the question.
>
> I would appreciate further help if you can.
>
> "Mayayana" wrote:
>
>> | Yes I will be the first to admit that i do not have any knowledge on
>> bit
>> | operations but so far this has not stopped me from getting useful code
>> to
>> | work to my requirements. I have read the article that Kevin Provance
>> | suggested at that has not helped me to understand the problem I have.
>> | As you said I had tried the prints to the intermediate window and I get
>> this
>> | result
>> |
>> | ? (17 and 16) <> 16 Result False
>> | ? (16 and 16) <> 16 Result False
>> | is this the correct answer? it seem from what you said it is. OK
>> |
>>
>> Since it's a bit flag you're comparing bit values. It's
>> misleading because "And" doesn't make sense
>> until you know that. The values in binary are:
>>
>> 16: 00010000
>> 17: 00010001
>>
>> So 17 And 16 = 16 because that is the sum of the shared
>> bits. By doing x And 16 you can check whether the 16 bit is
>> set. It doesn't matter which other bits are or are not set. "And"
>> is just a simple masking device. (If that doesn't make sense
>> you might want to look up how decimal/hex/binary values
>> express numbers and how that relates to bits.
>>
>>
>>
>> .
>>


From: Henning on
A little too fast, again...

If you want If (WFD.....) to satisfy when it is a Dir, then change <> to =.

/Henning

"Henning" <computer_hero(a)coldmail.com> skrev i meddelandet
news:i3k91o$s7a$1(a)news.eternal-september.org...
> OBS! 'if the object is *not* a folder
>
> /Henning
>
> "LondonLad" <LondonLad(a)discussions.microsoft.com> skrev i meddelandet
> news:68992D5B-C45F-47AF-9497-C7BE19587CB1(a)microsoft.com...
>> Hi Mayayana
>> Thank for your very clear explanation what would be the bit answer that
>> is
>> equal and allow code within the if statement to function.
>>
>> 'if the object is not a folder
>> If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <>
>> FILE_ATTRIBUTE_DIRECTORY Then
>>
>> other code
>>
>> End if
>>
>> I thought that the author was making sure that it was a folder its seems
>> to
>> me that when it is a folder it still does not become equal and therefore
>> does
>> not satisfy the question.
>>
>> I would appreciate further help if you can.
>>
>> "Mayayana" wrote:
>>
>>> | Yes I will be the first to admit that i do not have any knowledge on
>>> bit
>>> | operations but so far this has not stopped me from getting useful code
>>> to
>>> | work to my requirements. I have read the article that Kevin Provance
>>> | suggested at that has not helped me to understand the problem I have.
>>> | As you said I had tried the prints to the intermediate window and I
>>> get
>>> this
>>> | result
>>> |
>>> | ? (17 and 16) <> 16 Result False
>>> | ? (16 and 16) <> 16 Result False
>>> | is this the correct answer? it seem from what you said it is. OK
>>> |
>>>
>>> Since it's a bit flag you're comparing bit values. It's
>>> misleading because "And" doesn't make sense
>>> until you know that. The values in binary are:
>>>
>>> 16: 00010000
>>> 17: 00010001
>>>
>>> So 17 And 16 = 16 because that is the sum of the shared
>>> bits. By doing x And 16 you can check whether the 16 bit is
>>> set. It doesn't matter which other bits are or are not set. "And"
>>> is just a simple masking device. (If that doesn't make sense
>>> you might want to look up how decimal/hex/binary values
>>> express numbers and how that relates to bits.
>>>
>>>
>>>
>>> .
>>>
>
>


From: Larry Serflaten on

"LondonLad" <LondonLad(a)discussions.microsoft.com> wrote

> 'if the object is not a folder
> If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <>
> FILE_ATTRIBUTE_DIRECTORY Then
>
> I thought that the author was making sure that it was a folder


That code tests to see if the attributes say its NOT a folder.

If (MyValue And SOMETEST) = SOMETEST Then ' The tested attribute is present

If (MyValue And SOMETEST) <> SOMETEST Then ' The tested attribute is not present


LFS