Re: Differences between VB6 and VB.Net causing problem
- From: "Bill McCarthy" <Bill@xxxxxxxxxxxxx>
- Date: Sat, 18 Oct 2008 20:07:45 +1100
"Larry Serflaten" <serflaten@xxxxxxxxxxxxxx> wrote in message news:e1TKh6NMJHA.4772@xxxxxxxxxxxxxxxxxxxxxxx
"Bill McCarthy" <Bill@xxxxxxxxxxxxx> wrote
Oh, and for the record, VB6 and VB.NET do NOT store 0 and -1. For example,
try Dim x as Byte : x = True. Both will give you 255 which is the Not False
value for that data type :)
What do you get when you try to store True to a Decimal type? Are all bits
flipped there? (Oops - not the Not False value there, is it?)
Yeh my bad I should have said all bitwise types. Obviously String, TextBox, Form etc etc, don't have a bitwise state, nor do Decimal, Double, Single or Currency etc. For VB6 the list of bitwise types is reasonably small (bitwise types are the types you can use And, Or and XOr with) : Boolean, Integer, Byte and Long. For VB.NET it includes both the signed and unsigned byte, Itn16, Int32 and Int64 and Boolean.
In VB6, True is a 32 bit value with all bits set.
No it is not. It is 16 bit in Vb6. If you don't beleive the documentation try it yourself:
Private Type Foo
a As Boolean
b As Boolean
c As Boolean
d As Boolean
End Type
Dim x As Foo
Debug.Print LenB(x)
I get 8 bytes, which is 2 bytes (aka 16 bit) per Boolean.
In two's complement form
that is -1. If you try to stuff True into a smaller type, the higher order
bits are truncated. If you try to stuff True into a larger type, that type's
representation of -1 is used.
Nice theory but that isn't what happens. The defualt size in VB6 is 16 bit. I think what they do is a rotating right shift with carry, or jsut use logic expression for the conversion.
IOW:
If the Byte type was a signed type, the &HFF would be -1.
Right, but you are starting with &HFFFF, and that does not give you &HFFFFFFFF for a VB6 long nor does it give you &HFFFFFFFFFFFFFFFF for a VB.NET Int64. There's clearly some intervention at work ;)
.
- Follow-Ups:
- Re: Differences between VB6 and VB.Net causing problem
- From: Larry Serflaten
- 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
- Differences between VB6 and VB.Net causing problem
- Prev by Date: installation of internet explorer 8.0
- Next by Date: Re: installation of internet explorer 8.0
- 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