Mega Code Archive

 
Categories / VB.Net Tutorial / Data Type
 

Interpret numeric strings as a hexadecimal value and convert it to an unsigned long integer

Module Example    Public Sub Main()       Dim hexStrings() As String = { "8", "0FFFFFFF", "F00", "00A", "D"}       For Each hexString As String In hexStrings          Try             Dim number As UInteger = Convert.ToUInt32(hexString, 16)             Console.WriteLine("{0,18:N0}", number)          Catch e As FormatException             Console.WriteLine("{0,18}", "Bad Format")          Catch e As OverflowException             Console.WriteLine("{0,18}", "Numeric Overflow")          Catch e As ArgumentException             Console.WriteLine("{0,18}", "Invalid in Base 16")          End Try       Next                                                End Sub End Module