Re: Differences between VB6 and VB.Net causing problem
- From: Robert Morley <rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 20 Oct 2008 00:23:54 -0400
Okay, I'm royally confused at this point. See inline:
Larry Serflaten wrote:
What do you think the If bln = CByte(255) Then does ?Converts them both to the same type (Boolean) and does the compare.
CByte won't convert anything to boolean, it'll convert it to byte. Did you perhaps mean to use CBool?
Wrong. Did you try :
If bln = CByte(254) Then
We must not be observing the same results. The above test backs up
my statement, it does not refute it. I said the CByte(X) is evaluated to
a boolean and then the rest of the comparison is done. In the case of
255, CByte converts to True so the statement is True, and for 254
CByte converts to false so the statement is false.
Here again, CByte converts 255 to 255 and 254 to 254, not True or False, oddly enough. :) CBool would convert BOTH, and any other non-zero value, to True, not False.
If you did you would know your above statement is incorrect.
You don't see it the same as I.... I have to wonder if you even look.
Unless I'm missing out on something, I think you BOTH need to re-look!
Where do you get that? I'd say it converts the byte to a boolean.
See above. You are wrong. A very simple test can confirm this.
That test above proved my point, either you see a different result,
or you don't understand what you are seeing....
Other than the original CDec(True) statement, there were no Booleans involved in any of the remaining code that I saw...only Bytes and Decimals. This is why I'm confused. Was there something in Bill's posts (which I'm not seeing) that used Booleans?
Which is why I refuted your assumption that VB does not store -1
for True. All your statements are based on the wrong assumption....
I think I see the point here, since Byte is unsigned, CByte(True) returns 255 (which is of course all 1's when represented in binary, equivalent to -1 were it signed), and all other C<whatever>(True) functions return -1, so in some sense of the word, VB does store -1 for True as others have quoted the documentation as saying.
I think that the assertion that True = -1 is a bit of a misnomer, though, despite the documentation...it's simply the chosen representation when converted to an integer format.
Similarly, the assertion that True is all bitwise 1's in whatever numeric format is also incorrect. CSng(True) is a perfectly valid conversion, albeit a highly unlikely one, and it will indeed return -1, but it certainly doesn't return all bitwise 1's when examined at the bit level.
Any way, again I'm done with arguing with you on this. There is absolutely
no doubt you are wrong. There should also be no doubt that a Boolean is 16
bytes in VB6.
16 bytes?!? I think Bill must've meant 16 bits, and that much is easily proven with:
Dim bln As Boolean
Debug.Print Len(bln)
So anyway, what was the point of this debate? I really wasn't following it all, but the various erroneous statements made by both sides made what little I did read extremely hard to follow in any event.
If I understood correctly, the debate was whether or not True is represented as a 32-bit value, and I'm not sure it inherently HAS a number of bits. If it does, I would guess that it's a standard 16-bit Boolean value, converted to other formats based on VB6's design (in most normal cases where integer types are being used, this would mean it's truncated, converted directly, or sign-extended as appropriate). The assertion that it's 32 bits because Hex(CDec(True)) returns FFFFFFFF is erroneous, as Hex's limit is 32 bits, so the Decimal is being converted back down to a Long before Hex spits out its answer. You can easily prove this by trying:
Debug.Print Hex(CDec(2147483647))
Debug.Print Hex(CDec(2147483648))
The second one will, of course, generate an overflow.
Any questions or comments? Or am I wandering off on the wrong path?
Rob
.
- Follow-Ups:
- 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
- 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
- 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
- Differences between VB6 and VB.Net causing problem
- Prev by Date: Re: Differences between VB6 and VB.Net causing problem
- Next by Date: Re: Extended File properties
- 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
|
Loading