Assigning large UInt32 constants in VB.Net

Posted by Kumba on Stack Overflow See other posts from Stack Overflow or by Kumba
Published on 2011-01-04T04:45:32Z Indexed on 2011/01/04 4:53 UTC
Read the original article Hit count: 240

Filed under:

I inquired on VB's erratic behavior of treating all numerics as signed types back in this question, and from the accepted answer there, was able to get by. Per that answer:

Visual Basic Literals

Also keep in mind you can add literals to your code in VB.net and explicitly state constants as unsigned.

So I tried this:

Friend Const POW_1_32 As UInt32 = 4294967296UI

And VB.NET throws an Overflow error in the IDE. Pulling out the integer overflow checks doesn't seem to help -- this appears to be a flaw in the IDE itself.

This, however, doesn't generate an error:

Friend Const POW_1_32 As UInt64 = 4294967296UL

So this suggests to me that the IDE isn't properly parsing the code and understanding the difference between Int32 and UInt32. Any suggested workarounds and/or possible clues on when MS will make unsigned data types intrinsic to the framework instead of the hacks they currently are?

© Stack Overflow or respective owner

Related posts about vb.net