I'm new to VB.Net. I'm using a library call setInstance(ByVal instance As UInteger)
in my VB.Net code. The parameter I need to pass is an Integer. Is there anything I need to do to convert the integer parameter to an unsigned integer? The number is garunteed to be positive and less than 10.
views:
33answers:
3
+2
A:
Like so...
Dim MyInt As Int32 = 10
Dim MyUInt As UInt32 = CUInt(MyInt)
setInstance(MyUInt)
Carter
2010-07-16 16:44:37
A:
CuInt or Ctype( x, UInt ) allows convert a positive integer.
Throws exception when x is negative.
to Use Int as Uint, you can use some tricks:
dim bb() = System.BitConverter.GetBytes(myInt)
dim MyUint = System.BitConverter.ToUInt32(bb, 0)
Also with System.Buffer.BlockCopy for arrays.
If you configure Compiler to disable Check Integer Overflow (Default on Csharp). Then you can use CUint with negative values with no check - not exception.
x77
2010-07-16 17:45:44