Conert Hex to text

carnation
08-25-2009, 12:41 AM
Hi all,

I have some data in Hex, please show me how to convert hex to text.

Thanks a lot.

kassyopeia
08-25-2009, 01:19 AM
Do you mean that the data is in a binary file, or that you have the the hex representation as a string? If it's the former, you can just read the file into a string variable, no manual conversion is needed.* If it's the latter, you need to chop the string into two-character segments (using e.g. a For loop, Len() and Mid$()) and then convert each segment into a symbol, e.g. like this:

Private Function hexStrToChar(hexStr As String) As String
hexStrToChar = Chr$(CLng("&H" & hexStr))
End Function

CLng() converts the ascii-code from a hex-string to a number, Chr$() the ascii-code into the corresponding symbol.

Is that what you need? :)

ETA: *except maybe a StrConv(ToUnicode), not entirely sure at the moment.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum