How to decode a hex string in vb6

I find I’m always re-inventing the wheel when it comes to application development.  Hopefully this will become a useful library of code snippets that not only I will find useful, but the development community at large.  Feel free to ask any questions you may have on any items I post as I’m not likely to have time to provide a walk through for every post I make.

Private Sub Command1_Click()
Dim sStr As String
sStr = “0x74657374206161616120746573740D0A2D2D53595341444D”
Dim sResult As String
sResult = “”
Dim i As Integer
For i = 1 To Len(sStr) Step 2
sResult = sResult & (Chr(Val(“&H” & Mid(sStr, i, 2))))
Next i
Debug.Print sResult
End Sub

Leave a comment