现在有一串字符 A="$1*q3esdf *~AEFSEF嘃%k4?€i" ,如何将它们一个个变成十六进制的数,比如 3B 4C 00 34 5D 6F A0 2B.......  并且将这些数显示出来ListBox
中,显示的为:3B 4C 00 34 5D 6F A0 2B.......  ?

解决方案 »

  1.   

    dim strHex as string 
    dim strChr as string
    dim intI as integerfor intI=1 to Len(A)
      strChr=midb(strconv(A,vbFromUnicode),inti,1)
      strHex=strHex & Hex(asc(strChr))
    next inti马上下班,没有测试,如有问题。再讨论!
      

  2.   

    Dim strBuf as string
    dim strHexBuf as string
    dim i as longstrBuf=......
    for i=1 to len(strbuf)
        strhexbuf=strHexBuf  & Hex(Asc(mid(strBuf,i,1))) & " "
    next
      

  3.   

    同意MoQi_123(老莫的春天) 
    Dim strBuf as string
    dim strHexBuf as string
    dim i as longstrBuf=......
    for i=1 to len(strbuf)
        strhexbuf=strHexBuf  & Hex(Asc(mid(strBuf,i,1))) & " "
    next
    me.text1.text=strhexbuf
      

  4.   

    Private Sub Command1_Click()
    A = "$1*q3esdf *~AEFSEF?%k4??€i?"
        For iFor = 1 To Len(A)
            b = Mid(A, iFor, 1)
            List1.AddItem Hex(Asc(b))
        Next iForEnd SubPrivate Sub Command2_Click()
    s = ""
    For i = 0 To List1.ListCounts = s + Chr(Val("&H" & List1.List(i)))
    Next
    MsgBox s
    End Sub
      

  5.   

    Private Sub Command2_Click()
        Dim arr() As Byte
        Dim i As Integer
        Dim a As String
        Dim s As String
        a = "$1*q3esdf *~AEFSEF嘃%k4?€i"
        arr = StrConv(a, vbFromUnicode)
        For i = 0 To UBound(arr)
            s = s & Hex(arr(i)) & " "
        Next
        List1.AddItem s
        s = StrConv(arr, vbUnicode)
        Text2 = s
    End Sub