Mega Code Archive

 
Categories / VB.Net / Data Types
 

Parse string to Byte as System Globalization NumberStyles HexNumber

Imports System Module Example     Sub Main()          Dim string2 As String = "F9"         Try            Dim byte2 As Byte = Byte.Parse(string2,                                      System.Globalization.NumberStyles.HexNumber)            Console.WriteLine(byte2)         Catch e As OverflowException            Console.WriteLine("'{0}' is out of range of a byte.", string2)         Catch e As FormatException            Console.WriteLine("'{0}' is out of range of a byte.", string2)         End Try    End Sub End Module