AndAlso

  • Thread starter Thread starter Matt
  • Start date Start date
CBool(flag And &H10)

IMHO, it makes no sense to convert an integer to a Boolean. A boolean is
either True or False and has no value. I realize that there are API
functions that return 1 or some other integer to mean "true" but I think
you should test for that explicit condition:

If retval = 1 Then

Instead of

If CBool(retval) Then


Just my 2/100 of a dollar.
 
Chris Dunaway said:
On Sat, 10 Jan 2004 09:13:55 -0600, Otuse net wrote:
I realize that there are API
functions that return 1 or some other integer to mean "true" but I think
you should test for that explicit condition:

If retval = 1 Then
Instead of
If CBool(retval) Then


ACK. You could even take this one step further (if you are using *alot* of
integer results):

Public Const iTrue as Integer = 1
...
If retval = iTrue then


Just to eliminate magic numbers & make the flag more flexable.


~
Jeremy
 
The thing is, if flag And &H10 (an integer) is non-zero, it is &H10.
However, CBool(flag And &H10) will convert it to a field of all 1 bits
which is boolean "true." But that is only an implementation issue. You
are right that any individual implementation can use any internal
representation. Perhaps the best way is to do exactly what you are meaning
by doing the bitwise And: if (flag And &H10) <> 0 then.
 
Back
Top