问题:
串口得到如下数据:
+CMGL: 17,"REC UNREAD","8615007557713",,"10/03/30,09:37:15+32",145,48
0042004C0053005A00300030003000410030003000300036003300410033...
第2行就是unicode编码的文本,如何转换成文本?
方法一
Command1_Click()
Dim src As String
Dim dst As String
Dim length As Long
Dim i As Long
'转换后的结果:BLSZ000A00063A3
src = "0042004C0053005A00300030003000410030003000300036003300410033" '需要转换的文本
length = Len(src)
For i = 1 To length Step 4
dst = dst + ChrW(Val("&h" + Mid$(src, i, 4)))
Next
Me.Print dst
End Sub
方法二
Private Sub Command1_Click()
Dim strSj As String
Dim bytSj() As Byte
Dim l As Long
Dim i As Long
strSj = "0042004C0053005A00300030003000410030003000300036003300410033"
l = Len(strSj)
ReDim bytSj(l / 4 - 1)
For i = 1 To l Step 4
bytSj((i - 1) / 4) = Val("&H" & Mid(strSj, i + 2, 2))
Next
Me.Print StrConv(bytSj, vbUnicode)
End Sub