2019/05/28

二進位陣列串接 合併

字串串接 A$ = A$ + B$ 方式簡單

但是陣列就不使用上列方式

使用API方式串接陣列


' 使用API

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Dest As Any, Src As Any, ByVal cb&)


If (Not AllBytes) = -1 Then                                         ' 判斷陣列是否有初始化

     AllBytes = buf

Else

     NewBytesLength = UBound(buf()) + 1                              ' 新資料個數

     AllBytesLength = UBound(AllBytes())                             ' 原資料個數

     ReDim Preserve AllBytes(0 To AllBytesLength + NewBytesLength)     ' 重新定義陣列,並保留資料

     CopyMemory AllBytes(AllBytesLength + 1), buf(0), NewBytesLength  ' 資料串接合併

End If



其中 If (Not AllBytes) = -1 Then , 為判斷陣列裡面是否有資料