Re: Differences between VB6 and VB.Net causing problem
- From: "Larry Serflaten" <serflaten@xxxxxxxxxxxxxx>
- Date: Sun, 19 Oct 2008 02:12:01 -0500
"Bill McCarthy" <Bill@xxxxxxxxxxxxx> wrote
You are saying -1 doens't equal 255; yet True does
Didn't you see, 255 does not equal True. The value of True is -1.
A Byte value cannot represent a negative number.
What do you think the If bln = CByte(255) Then does ?
Converts them both to the same type (Boolean) and does the compare.
As I said, they may have made the decision to allow a conversion between
Byte and Boolean. In that case the byte value 255 is the only logical choice
in keeping with the rest of the language. When you force them to be in
identical types, 255 will not equal -1.
Seriosuly I am curious as to why you think that is "appels to oranges" when the rules
for the comparison dictate that the boolean is converted to a byte.
Where do you get that? I'd say it converts the byte to a boolean.
In case you forgot, the If <condition> has to evaluate to a boolean and
one of the operands is already a boolean type. So that one-off conversion
converts CByte(255) to a Boolean value of True and the comparison continues.
How many times do I have to tell you Decimal, Single and Double are not
bitwise types ?
No. It's actually to do with **bitwise** operations.
What makes Integer and Long bitwise types? The fact that they work
in logical/bitwise operations? So does Decimal....
v1 = CDec(&HFA)
v2 = CDec(&HAF)
Debug.Print Hex(v1 And v2)
Here's an interesting exercise:
? Hex(Not CByte(0))
? Hex(Not CBool(0))
? Hex(Not CInt(0))
? Hex(Not CDate(0))
? Hex(Not CLng(0))
? Hex(Not CSng(0))
? Hex(Not CDbl(0))
? Hex(Not CCur(0))
? Hex(Not CDec(0))
? Hex(Not CStr(0)) ' <<< It can pick any data size it wants, yet 32 bits is shown.
It sure appears to me that given the space to do so, True represents
a 32 bit number whose value is -1.
LFS
.
- Follow-Ups:
- Re: Differences between VB6 and VB.Net causing problem
- From: Bill McCarthy
- Re: Differences between VB6 and VB.Net causing problem
- References:
- Differences between VB6 and VB.Net causing problem
- From: Howard G
- Re: Differences between VB6 and VB.Net causing problem
- From: Tom Shelton
- Re: Differences between VB6 and VB.Net causing problem
- From: expvb
- Re: Differences between VB6 and VB.Net causing problem
- From: Tom Shelton
- Re: Differences between VB6 and VB.Net causing problem
- From: Bill McCarthy
- Re: Differences between VB6 and VB.Net causing problem
- From: Larry Serflaten
- Re: Differences between VB6 and VB.Net causing problem
- From: Bill McCarthy
- Re: Differences between VB6 and VB.Net causing problem
- From: Larry Serflaten
- Re: Differences between VB6 and VB.Net causing problem
- From: Bill McCarthy
- Re: Differences between VB6 and VB.Net causing problem
- From: Larry Serflaten
- Re: Differences between VB6 and VB.Net causing problem
- From: Bill McCarthy
- Differences between VB6 and VB.Net causing problem
- Prev by Date: Re: Differences between VB6 and VB.Net causing problem
- Next by Date: Re: Differences between VB6 and VB.Net causing problem
- Previous by thread: Re: Differences between VB6 and VB.Net causing problem
- Next by thread: Re: Differences between VB6 and VB.Net causing problem
- Index(es):
Relevant Pages
|