28
Mar
09

[VB.Net] Hex to String Conversion

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

Usage:

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

Would output:
sim0n

Advertisements

2 Responses to “[VB.Net] Hex to String Conversion”


  1. May 11, 2009 at 10:18 pm

    Thanks a lot for the code! And for the String to Hex too 😀 😀


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: