Wednesday, March 26, 2014

hex to string conversion

This is an example of  hex to string:


Function HexToString(ByVal hex As String) As String
    Dim text As New System.Text.StringBuilder(hex.Length \ 2)
    For i As Integer = 0 To hex.Length - 2 Step 2
        text.Append(Chr(Convert.ToByte(hex.Substring(i, 2), 16)))
    Next
    Return text.ToString
End Function

How to use:

Console.WriteLine(HexToString("73696D306E"))

No comments:

Post a Comment