请问各位高手:
  怎样将一串十六进制的字符串转换成相应的汉字或字母(可能是汉字与字母或数字组成)由于小弟对进制转换不熟,请详细指教,小弟万分感激

解决方案 »

  1.   

    Option ExplicitPrivate Sub Command1_Click()
      Dim s As String
      s = String2Hex("今天abc123")
      MsgBox s
      s = Hex2String(s)
      MsgBox s
    End SubPrivate Function String2Hex(ByVal s As String) As String
        On Error Resume Next
        Dim bytearr() As Byte
        bytearr = StrConv(s, vbFromUnicode)
        Dim temps As String
        Dim temp As Byte
        Dim i As Long
        Dim outs As String
        For i = 0 To UBound(bytearr)
            temp = bytearr(i)
            temps = Hex(temp)
            temps = Right("00" + temps, 2)
            outs = outs + temps
        Next
        String2Hex = outs
    End Function
    Private Function Hex2String(ByVal s As String) As String
        On Error Resume Next
        Dim bytearr() As Byte
        Dim temps As String
        Dim temp As Byte
        Dim i As Long
        Dim j As Long
        j = 0
        Dim outs As String
        For i = 1 To Len(s) Step 2
            temps = Mid(s, i, 2)
            temp = Val("&H" & temps)
            ReDim Preserve bytearr(j)
            bytearr(j) = temp
            j = j + 1
        Next
        outs = StrConv(bytearr, vbUnicode)
        Hex2String = outs
    End Function
      

  2.   

    楼上正解。Function tohanzi(ByVal data As String) As StringDim i As Long
    For i = 1 To Len(data) Step 4
    tohanzi = tohanzi & Chr("&H" & Mid(data, i, 2))
    Next
    End FunctionPrivate Sub Command2_Click()
    Const data = "B2D2C2AE"
    MsgBox tohanzi(data)
    End Sub
      

  3.   

    Function tohanzi(ByVal data As String) As StringDim i As Long
    For i = 1 To Len(data) Step 4
    tohanzi = tohanzi & Chr("&H" & Mid(data, i, 4))
    Next
    End FunctionPrivate Sub Command2_Click()
    Const data = "B2D2C2AE"
    MsgBox tohanzi(data)
    End Sub