Mega Code Archive

 
Categories / VB.Net / Development
 

Convert hex string to Int16

Module Example    Public Sub Main()       Dim hexStrings() As String = { "8000", "0FFF", "f000", "00A30", "D", _                                      "-13", "9AC61", "GAD" }       For Each hexString As String In hexStrings          Try             Dim number As Short = Convert.ToInt16(hexString, 16)             Console.WriteLine("Converted '{0}' to {1:N0}.", hexString, number)          Catch e As Exception             Console.WriteLine("Exception")          End Try       Next                                                End Sub End Module