dim a as long
a=-200
dim b as integer
dim c as integerb = ( (a + 256) \ 16 ) mod 16
c = ( a + 256 ) mod 16

解决方案 »

  1.   

    Private Sub Command4_Click()
        Dim a As String
        a = "xxxx榲大小上下"
        'ascii  120 120 120 120 152 118
        'hex    78  78  78  78  98  76
        'in  vb 120 120 120 120 -26506
        'vb hex 78  78  78  78  &h9876
        Dim b As String
        Dim aa As Integer
        Dim bb As Integer
        Dim i As Integer
        Dim c As String
        For i = 1 To Len(a)
            b = Mid(a, i, 1)
            If Asc(b) < 0 Then
                '汉字,代表4个压缩数据,如上,代表9876
                aa = (Asc(b) + 65536) \ 256 Mod 256
                bb = (Asc(b) + 65536) Mod 256
                c = c & Hex(aa) & Hex(bb)
            Else
                '字母
                c = c & b
            End If
        Next i
        Debug.Print c
    End Sub
    运行结果
    xxxx9876B4F3D0A1C9CFCFC2