Mega Code Archive

 
Categories / VB.Net / Development
 

Convert ToUInt32 (Decimal) converts decimal number to 32-bit unsigned integer

Class Sample    Public Shared Sub Main()         Dim values() As Decimal = { Decimal.MinValue, -1034.23d, -12d, 0d, 147d, _                                     199.55d, 2010.16d, Decimal.MaxValue }         Dim result As UInteger                  For Each value As Decimal In values            Try               result = Convert.ToUInt32(value)               Console.WriteLine(result)            Catch e As OverflowException               Console.WriteLine("{0} is outside the range of the UInt32 type.", _                                 value)            End Try            Next                                       End Sub  End Class