EXCEL 把十六进制字符串转成ASCII

Sub 把十六进制字符串转成ASCII()

Dim i As Integer '这句定义变量
Dim x As Integer '这句定义变量
Dim str As String '这句定义变量
Dim firstChar As Integer '这句定义变量
Dim secondChar As Integer '这句定义变量
For i = 3 To Range("C65536").End(xlUp).Row

str = ""
For x = 1 To Len(Sheet1.Cells(i, 3)) Step 3

'MsgBox Mid(Sheet1.Cells(i, 2).Text, x, 2)
str = str + Chr(Val("&H" + Mid(Sheet1.Cells(i, 3).Text, x, 2)))

Next x

firstChar = Val("&H" + Mid(Sheet1.Cells(i, 3).Text, 1, 2))
secondChar = Val("&H" + Mid(Sheet1.Cells(i, 3).Text, 4, 2))
If firstChar = 13 And secondChar = 10 Then

Sheet1.Cells(i, 3) = str
End If

Next i
End Sub

 

你可能感兴趣的:(工作记录,VB)