Wendell
06-23-2007, 06:51 AM
Hello
I am no VBA person, and I really don't understand the syntax, but I am looking for a function that will convert a Hex string to its ASCII equivalent. I have searched the net for an appropriate UDF in VB that can be used to accomplish this simple task, I came up with the following:
Function dehex(str As String) As String
Dim I As Long
For I = 1 To Len(str) Step 2
dehex = dehex & Chr( _
InStr(1, "0123456789ABCDEF", Mid(str, I, 1)) * 16 - 16 _
+ InStr(1, "0123456789ABCDEF", Mid(str, I + 1, 1)) - 1)
Next I
End Function
Unfortunately this did not convert the Hex string correctly when applied to the column in Excel e.g.
Hex string: 43616c6c20206d65
Converted ASCII String: Ca__ _e
In ASCII this should read as: Call me
Please can anyone who knows VB take a look and make some suggestions...
Wendell:banghead:
I am no VBA person, and I really don't understand the syntax, but I am looking for a function that will convert a Hex string to its ASCII equivalent. I have searched the net for an appropriate UDF in VB that can be used to accomplish this simple task, I came up with the following:
Function dehex(str As String) As String
Dim I As Long
For I = 1 To Len(str) Step 2
dehex = dehex & Chr( _
InStr(1, "0123456789ABCDEF", Mid(str, I, 1)) * 16 - 16 _
+ InStr(1, "0123456789ABCDEF", Mid(str, I + 1, 1)) - 1)
Next I
End Function
Unfortunately this did not convert the Hex string correctly when applied to the column in Excel e.g.
Hex string: 43616c6c20206d65
Converted ASCII String: Ca__ _e
In ASCII this should read as: Call me
Please can anyone who knows VB take a look and make some suggestions...
Wendell:banghead: