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

沒有留言:

張貼留言

2023 Promox on Morefine N6000 16GB 512GB

2023 Promox on Morefine N6000 16GB 512GB Software Etcher 100MB (not but can be rufus-4.3.exe 1.4MB) Proxmox VE 7.4 ISO Installer (1st ISO re...