2015年8月12日 星期三

VBA Code in Excel to Convert Hex to ASCII String

VBA Code

Public Function hex2ascii(ByVal hextext As String) As String
 
For y = 1 To Len(hextext)
    num = Mid(hextext, y, 2)
    Value = Value & Chr(Val("&h" & num))
    y = y + 1
Next y

hex2ascii = Value
End Function


Usage:

=hex2ascii("4C4C322E5431534F")

Output:

LL2.T1SO






Public Function ascii2hex(EvalString As String) As String
Dim intStrLen As Integer
Dim intLoop As Integer
Dim strHex As String

EvalString = Trim(EvalString)
intStrLen = Len(EvalString)
For intLoop = 1 To intStrLen
strHex = strHex & Hex(Asc(Mid(EvalString, intLoop, 1)))
Next
ascii2hex = strHex
End Function



Usage:

=hex2ascii("LL2.T1SO")

Output:

4C4C322E5431534F

沒有留言:

張貼留言

2007 to 2023 HP and Dell Servers Comparison

  HP Gen5 to Gen11  using ChatGPT HP ProLiant Gen Active Years CPU Socket Popular HP CPUs Cores Base Clock Max RAM Capacity Comparable Dell ...