如题

解决方案 »

  1.   

    如果是简单的
    dim b1(1) as byte
    dim b2(0) as byte
    dim b3(0) as byte
    b1(0)=b1(0)
    b1(1)=b3(0)
    比较长的则用copymemory
      

  2.   

    dim b1 as byte,b2 as byte,b3 as byte
    b3=b1+b2
    是这个意思吗?
      

  3.   

    To;VBToy() 
    具体怎么用,没看明白
      

  4.   

    To:boywang(大力水手) 
    dim b1 as byte,b2 as byte,b3 as byte
    b3=b1+b2
    是一种
    还有b1=b1+b2怎么相加
      

  5.   

    copymemory怎么使用将两个Byte相加
      

  6.   

    如果不是简单相加,而时将bytes连接起来,并且比较长的话,可以用如下方式:将b2,b3连接起来存入b1中:
    dim b1() as byte
    dim b2() as byte
    dim b3() as byte
    dim m as integer,n as integer,L as integerredim b2(1 to m)
    redim b3(1 to n)
    L=m+n
    redim b1(1 to L)
    copymemory b1(1),b2(1),m '复制b2到b1
    copymemory b2(m+1),b3(1),n '复制b3到b1,加到b2后面
      

  7.   

    改正:
    copymemory b1(m+1),b3(1),n '复制b3到b1,加到b2后面
      

  8.   

    copymemory b2(m+1),b3(1),n '复制b3到b1,加到b2后面
    应该是
    copymemory b1(m+1),b3(1),n '复制b3到b1,加到b2后面吧
      

  9.   

    我要效果就是b1=b1+b2不是值相加,是把b2追加到b1h ,就是相当于把b1、b2连起来就可以了
      

  10.   

    dim i as integer,b1 as byte,b2 as byte
    i=b1 * &h100 +b2
      

  11.   

    为什么数组有值的时候就出错了
    如下数据源
    Byte1(0)=84
    Byte1(1)=101
    Byte1(2)=120
    Byte1(3)=116
    Byte1(4)=49Byte2(0)=226
    Byte2(1)=70
    Byte2(2)=188
    实现效果为
    Byte1(0)=84
    Byte1(1)=101
    Byte1(2)=120
    Byte1(3)=116
    Byte1(4)=49
    Byte1(5)=226
    Byte1(6)=70
    Byte1(7)=188
      

  12.   

    dim b1 as byte
    dim b2 as byte
    dim b3 as byte
    b3 = (b1 and &hf0) + (b2 and &h0f)就是这样 取b1的高4位和b2的低4位合并到b3
      

  13.   

    To WallesCai(沧海明月一度,西风残阳无悔.) 
    dim b1 as byte
    dim b2 as byte
    dim b3 as byte
    b3 = (b1 and &hf0) + (b2 and &h0f)就是这样 取b1的高4位和b2的低4位合并到b3
      
    提示错误:在and处提示类型不匹配
      

  14.   

    To VBToy() 
    dim b1() as byte
    dim b2() as byte
    dim b3() as byte
    dim m as integer,n as integer,L as integerredim b2(1 to m)
    redim b3(1 to n)
    L=m+n
    redim b1(1 to L)
    copymemory b1(1),b2(1),m '复制b2到b1
    copymemory b2(m+1),b3(1),n '复制b3到b1,加到b2后面m、n的初始值为多少?你试过吗?不成功啊  
      

  15.   

    m,n是byte数组的长度,取决于你的需要。另外
    copymemory b2(m+1),b3(1),n '复制b3到b1,加到b2后面
    应该是
    copymemory b1(m+1),b3(1),n '复制b3到b1,加到b2后面
      

  16.   

    dim b1() as byte
    dim b2() as byte
    dim b3() as byte
    dim m as integer,n as integer,L as integerredim b2(1 to m)
    redim b3(1 to n)
    L=m+n
    redim b1(1 to L)
    copymemory b1(m+1),b3(1),n '复制b3到b1,加到b2后面m、n需要赋值的吧,运行通不过,出错了
      

  17.   

    如果真只有两个byte,那就不要copymemory了,楼上星星们的招数就可以了,简单,安全!
      

  18.   

    你的意思是 把两个字节连在一起 形成一个双字节
    对吗 通过数组完成 数组在内存中是连续的第二 是通过VC中的双字节完成 我不知道VB有没有
      

  19.   

    dim str as string
    str = chrb(byte1) & chrb(byte2)
    msgbox str
    msgbox strconv(str, vbunicode)
      

  20.   

    Option ExplicitPrivate Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
                            Destination As Any, _
                            Source As Any, _
                            ByVal Length As Long)
                            
                            
    Public Function ArrayLink(ByRef a1() As Byte, _
                              ByRef a2() As Byte, _
                              ByRef r() As Byte) As Boolean
    On Error GoTo Proc_Error
        ArrayLink = True
        Dim lLength1 As Long, lLength2 As Long, lLength3 As Long
        Dim pWritePoint As Long
        pWritePoint = 0
        lLength1 = UBound(a1) + 1
        lLength2 = UBound(a2) + 1
        lLength3 = lLength1 + lLength2
        ReDim r(lLength3 - 1)
        CopyMemory r(pWritePoint), a1(0), lLength1
        pWritePoint = lLength1
        CopyMemory r(pWritePoint), a2(0), lLength2
        Exit Function
    Proc_Error:
        ArrayLink = False
    End FunctionPublic Function ArrayInsert(ByRef a1() As Byte, _
                                ByRef a2() As Byte, _
                                ByRef r() As Byte, _
                                ByVal lStart As Long) As Boolean
    On Error GoTo Proc_Error
        ArrayInsert = True
        Dim lLength1 As Long, lLength2 As Long, lLength3 As Long
        Dim pWritePoint As Long
        pWritePoint = 0
        lLength1 = UBound(a1) + 1
        lLength2 = UBound(a2) + 1
        lLength3 = lLength1 + lLength2
        If lStart > lLength1 Then GoTo Proc_Error
        ReDim r(lLength3 - 1)
        CopyMemory r(pWritePoint), a1(0), lStart
        pWritePoint = lStart
        CopyMemory r(pWritePoint), a2(0), lLength2
        pWritePoint = pWritePoint + lLength2
        CopyMemory r(pWritePoint), a1(lStart), lLength1 - lStart
        Exit Function
    Proc_Error:
        ArrayInsert = False
    End FunctionPublic Function ArrayReplace(ByRef a1() As Byte, _
                                 ByRef a2() As Byte, _
                                 ByRef r() As Byte, _
                                 ByVal lStart As Long, _
                                 ByVal lLength As Long) As Boolean
    On Error GoTo Proc_Error
        ArrayReplace = True
        Dim lLength1 As Long, lLength2 As Long, lLength3 As Long
        Dim pWritePoint As Long
        pWritePoint = 0
        lLength1 = UBound(a1) + 1
        lLength2 = UBound(a2) + 1
        lLength3 = lLength1 + lLength2 - lLength
        If lStart + lLength > lLength1 Then GoTo Proc_Error
        ReDim r(lLength3 - 1)
        CopyMemory r(pWritePoint), a1(0), lStart
        pWritePoint = lStart
        CopyMemory r(pWritePoint), a2(0), lLength2
        pWritePoint = pWritePoint + lLength2
        CopyMemory r(pWritePoint), a1(lStart + lLength), lLength1 - lStart - lLength
        Exit Function
    Proc_Error:
        ArrayReplace = False
    End FunctionPublic Function ArrayCopy(ByRef aDestination() As Byte, _
                            ByRef aSource() As Byte, _
                            Optional ByVal lStart As Long = -1, _
                            Optional ByVal lLength As Long = -1) As Boolean
    On Error GoTo Proc_Error
        ArrayCopy = True
        If lStart = -1 Then lStart = 0
        If lLength = -1 Then lLength = UBound(aSource) + 1
        If lStart + lLength > UBound(aSource) + 1 Then GoTo Proc_Error
        ReDim aDestination(lLength - 1)
        CopyMemory aDestination(0), aSource(lStart), lLength
        Exit Function
    Proc_Error:
        ArrayCopy = False
    End Function'=====================================================================其中ArrayLink()函数就是你想要的连接功能了dim a() as byte 
    dim b() as byte 
    dim c() as byte 
    ........
    .......
    ........
    arraylink a,b,c将A和B连接起来用C返回
      

  21.   

    dim b1() as byte
    dim b2() as byte
        
    Dim n As Long, j As Long
        n = UBound(b1) + 1
        j = UBound(b2) + 1    ReDim Preserve b1(n + j - 1)
        CopyMemory b1(n), b2(0), j将b2追加到b1
      

  22.   

    呵呵,有意思。其实最好的还是  iambluebird(胡搅蛮缠)