This is a Bug, but whose? VB.Net or Mine?

  • Thread starter Thread starter Jim Parsells
  • Start date Start date
J

Jim Parsells

Using VS2008 targeted at Framework 2.0 on XP SP3 (32 bit)

Given the following Enums:
<Flags()> _
Public Enum EMethod As UInteger
Buffered = 0
InDirect = 1
OutDirect = 2
Neither = 3
End Enum

<Flags()> _
Public Enum EFileDevice As UInteger
Beep = &H1
CDRom = &H2
CDRomFileSytem = &H3
Controller = &H4
Datalink = &H5
Dfs = &H6
Disk = &H7
DiskFileSystem = &H8
FileSystem = &H9
 
Jim Parsells said:
Using VS2008 targeted at Framework 2.0 on XP SP3 (32 bit)

Given the following Enums:
<Flags()> _
Public Enum EMethod As UInteger
Buffered = 0
InDirect = 1
OutDirect = 2
Neither = 3
End Enum

<Flags()> _
Public Enum EFileDevice As UInteger
Beep = &H1
CDRom = &H2
CDRomFileSytem = &H3
Controller = &H4
Datalink = &H5
Dfs = &H6
Disk = &H7
DiskFileSystem = &H8
FileSystem = &H9
.
. (more --removed for clarity)
.
End Enum

I declare another Enum:

Public Enum EIOControlCode As UInteger
.
.
FsctlSetCompression = (EFileDevice.FileSystem << 16) Or (16 << 2)
Or
EMethod.Buffered Or ((FileAccess.Read Or FileAccess.Write) << 14)
.
.
End Enum

Elsewhere, I declare two variables:

Dim X As EIOControlCode = EIOControlCode.FsctlSetCompression
Dim Y as UInteger
Y=(EFileDevice.FileSystem << 16) Or (16 << 2) Or EMethod.Buffered Or
((FileAccess.Read Or FileAccess.Write) << 14)

and observe that variable X has the hex value of 639040 (wrong)
and that variable Y has the hex value of 9C040 (correct)

Note that the code setting Y is exactly the same as the code setting the
Enum element.

Same code, different results. The only difference is that the Wrong
results
are a product of VB.Net's evaluation of the code in the Enum at compile
time
whereas the correct results are produced at run time.

The problem, of course is that the EIOControlCode Enum runs to over 100
entries which I now have to consider suspect at best.

Any help will be appreciated.


Sorry, but I get 9c040 for both values. Double check your formatting of the
output? 639040 is 9c040 expressed as an integer.
 
Jim Parsells said:
Using VS2008 targeted at Framework 2.0 on XP SP3 (32 bit)

Given the following Enums:
<Flags()> _
Public Enum EMethod As UInteger
Buffered = 0
InDirect = 1
OutDirect = 2
Neither = 3
End Enum

<Flags()> _
Public Enum EFileDevice As UInteger
Beep = &H1
CDRom = &H2
CDRomFileSytem = &H3
Controller = &H4
Datalink = &H5
Dfs = &H6
Disk = &H7
DiskFileSystem = &H8
FileSystem = &H9
.
. (more --removed for clarity)
.
End Enum

I declare another Enum:

Public Enum EIOControlCode As UInteger
.
.
FsctlSetCompression = (EFileDevice.FileSystem << 16) Or (16 << 2)
Or
EMethod.Buffered Or ((FileAccess.Read Or FileAccess.Write) << 14)
.
.
End Enum

Elsewhere, I declare two variables:

Dim X As EIOControlCode = EIOControlCode.FsctlSetCompression
Dim Y as UInteger
Y=(EFileDevice.FileSystem << 16) Or (16 << 2) Or EMethod.Buffered Or
((FileAccess.Read Or FileAccess.Write) << 14)

and observe that variable X has the hex value of 639040 (wrong)
and that variable Y has the hex value of 9C040 (correct)

Note that the code setting Y is exactly the same as the code setting the
Enum element.

Same code, different results. The only difference is that the Wrong
results
are a product of VB.Net's evaluation of the code in the Enum at compile
time
whereas the correct results are produced at run time.

The problem, of course is that the EIOControlCode Enum runs to over 100
entries which I now have to consider suspect at best.

Any help will be appreciated.


Sorry, but I get 9c040 for both values. Double check your formatting of the
output? 639040 is 9c040 expressed as an integer.
 
Jim said:
Using VS2008 targeted at Framework 2.0 on XP SP3 (32 bit)
.
FsctlSetCompression = (EFileDevice.FileSystem << 16) Or (16 << 2) Or
EMethod.Buffered Or ((FileAccess.Read Or FileAccess.Write) << 14)
.
Dim X As EIOControlCode = EIOControlCode.FsctlSetCompression
Dim Y as UInteger
Y=(EFileDevice.FileSystem << 16) Or (16 << 2) Or EMethod.Buffered Or
((FileAccess.Read Or FileAccess.Write) << 14)

and observe that variable X has the hex value of 639040 (wrong)
and that variable Y has the hex value of 9C040 (correct)

Any help will be appreciated.

I can't repeat it. I get 9C040 for both. How are you displaying the
hex?

writeline("x = {0,8}",Hex(x))
writeline("x = {0:X8}",CType(x,Uinteger))
writeline("y = {0:X8}",y)

x = 9C040
x = 0009C040
y = 0009C040

--
 
Jim said:
Using VS2008 targeted at Framework 2.0 on XP SP3 (32 bit)
.
FsctlSetCompression = (EFileDevice.FileSystem << 16) Or (16 << 2) Or
EMethod.Buffered Or ((FileAccess.Read Or FileAccess.Write) << 14)
.
Dim X As EIOControlCode = EIOControlCode.FsctlSetCompression
Dim Y as UInteger
Y=(EFileDevice.FileSystem << 16) Or (16 << 2) Or EMethod.Buffered Or
((FileAccess.Read Or FileAccess.Write) << 14)

and observe that variable X has the hex value of 639040 (wrong)
and that variable Y has the hex value of 9C040 (correct)

Any help will be appreciated.

I can't repeat it. I get 9C040 for both. How are you displaying the
hex?

writeline("x = {0,8}",Hex(x))
writeline("x = {0:X8}",CType(x,Uinteger))
writeline("y = {0:X8}",y)

x = 9C040
x = 0009C040
y = 0009C040

--
 
OK guys ...
Silly me, I had clicked the Hex button in VS2008 and ASSUMED that it would
show me all the values in Hex. I just never pushed beyond that to see what
the actual hex was for the result it was showing as I hovered the mouse over
the various variables. Hmmm ... it did show the Hex of everything not
expressed as a member of the Enum in question. Somehow I just missed the fact
that 639040 did not have &H prepended.

Thanks.
 
OK guys ...
Silly me, I had clicked the Hex button in VS2008 and ASSUMED that it would
show me all the values in Hex. I just never pushed beyond that to see what
the actual hex was for the result it was showing as I hovered the mouse over
the various variables. Hmmm ... it did show the Hex of everything not
expressed as a member of the Enum in question. Somehow I just missed the fact
that 639040 did not have &H prepended.

Thanks.
 
Back
Top