From: Karl E. Peterson on
MikeD pretended :
> "Karl E. Peterson" <karl(a)exmvps.org> wrote...
>> After serious thinking Nobody wrote :
>>> Use "ByVal 1&" to pass TRUE to API functions.
>>
>> Most API functions use 0 for False, and <>0 as True, though, just as VB
>> does. Occassionally you run across the dipsh!t subsystem coder who tested
>> for a specific value, but those are very rare.
>
> Yes, but there's really no way of knowing which API functions specifically
> are coded to be 1 and which are coded to be <>0; so, to be safe, it's best
> (at least IMO) to always use 1 for an API TRUE. Not -1 and not VB's
> intrinsic True.

Nothing wrong with erring on the side of correctness, I suppose. <g> I
tend to use True myself, until I get "unexpected" results, because I
find the code more readable that way. Trade-offs, huh?

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


From: Nobody on
"Karl E. Peterson" <karl(a)exmvps.org> wrote in message
news:umIEi9vkKHA.2132(a)TK2MSFTNGP05.phx.gbl...
> MikeD pretended :
>> "Karl E. Peterson" <karl(a)exmvps.org> wrote...
>>> After serious thinking Nobody wrote :
>>>> Use "ByVal 1&" to pass TRUE to API functions.
>>>
>>> Most API functions use 0 for False, and <>0 as True, though, just as VB
>>> does. Occassionally you run across the dipsh!t subsystem coder who
>>> tested for a specific value, but those are very rare.
>>
>> Yes, but there's really no way of knowing which API functions
>> specifically are coded to be 1 and which are coded to be <>0; so, to be
>> safe, it's best (at least IMO) to always use 1 for an API TRUE. Not -1
>> and not VB's intrinsic True.
>
> Nothing wrong with erring on the side of correctness, I suppose. <g> I
> tend to use True myself, until I get "unexpected" results, because I find
> the code more readable that way. Trade-offs, huh?

Using "True" in API parameter declared as BOOL, which is 4 bytes works if
the declaration in VB uses "As Long". If the VB declaration uses As Any,
which is rare, then VB would only pass 2 bytes, which is a problem.


From: Karl E. Peterson on
Nobody was thinking very hard :
> "Karl E. Peterson" <karl(a)exmvps.org> wrote in message
> news:umIEi9vkKHA.2132(a)TK2MSFTNGP05.phx.gbl...
>> MikeD pretended :
>>> "Karl E. Peterson" <karl(a)exmvps.org> wrote...
>>>> After serious thinking Nobody wrote :
>>>>> Use "ByVal 1&" to pass TRUE to API functions.
>>>>
>>>> Most API functions use 0 for False, and <>0 as True, though, just as VB
>>>> does. Occassionally you run across the dipsh!t subsystem coder who
>>>> tested for a specific value, but those are very rare.
>>>
>>> Yes, but there's really no way of knowing which API functions specifically
>>> are coded to be 1 and which are coded to be <>0; so, to be safe, it's best
>>> (at least IMO) to always use 1 for an API TRUE. Not -1 and not VB's
>>> intrinsic True.
>>
>> Nothing wrong with erring on the side of correctness, I suppose. <g> I
>> tend to use True myself, until I get "unexpected" results, because I find
>> the code more readable that way. Trade-offs, huh?
>
> Using "True" in API parameter declared as BOOL, which is 4 bytes works if the
> declaration in VB uses "As Long". If the VB declaration uses As Any, which is
> rare, then VB would only pass 2 bytes, which is a problem.

Good point. I'd only amend that to say "which _may_ be a problem."

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


From: Ralph on
Karl E. Peterson wrote:
> Nobody was thinking very hard :
>>
>> Using "True" in API parameter declared as BOOL, which is 4 bytes
>> works if the declaration in VB uses "As Long". If the VB declaration
>> uses As Any, which is rare, then VB would only pass 2 bytes, which
>> is a problem.
>
> Good point. I'd only amend that to say "which _may_ be a problem."

But if it is - it WILL always happen at 5:30pm just at the start of a 3 day
weekend with the family packed and waiting.

-ralph


From: Karl E. Peterson on
Nobody was thinking very hard :
> "Karl E. Peterson" <karl(a)exmvps.org> wrote in message
> news:umIEi9vkKHA.2132(a)TK2MSFTNGP05.phx.gbl...
>> MikeD pretended :
>>> "Karl E. Peterson" <karl(a)exmvps.org> wrote...
>>>> After serious thinking Nobody wrote :
>>>>> Use "ByVal 1&" to pass TRUE to API functions.
>>>>
>>>> Most API functions use 0 for False, and <>0 as True, though, just as VB
>>>> does. Occassionally you run across the dipsh!t subsystem coder who
>>>> tested for a specific value, but those are very rare.
>>>
>>> Yes, but there's really no way of knowing which API functions specifically
>>> are coded to be 1 and which are coded to be <>0; so, to be safe, it's best
>>> (at least IMO) to always use 1 for an API TRUE. Not -1 and not VB's
>>> intrinsic True.
>>
>> Nothing wrong with erring on the side of correctness, I suppose. <g> I
>> tend to use True myself, until I get "unexpected" results, because I find
>> the code more readable that way. Trade-offs, huh?
>
> Using "True" in API parameter declared as BOOL, which is 4 bytes works if the
> declaration in VB uses "As Long". If the VB declaration uses As Any, which is
> rare, then VB would only pass 2 bytes, which is a problem.

Good point. I'd only amend that to say "which _may_ be a problem."

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