vb6.0vba [vba] JoinBytesArray 함수를 이용한 Byte 조인하기
페이지 정보
본문
'// Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal cbLength As Long)
Public Function JoinBytesArray(ParamArray ByteArrays() As Variant) As Byte()
Dim sizeArray As Variant, startIndex As Long, i As Integer
Dim Buffer() As Byte, ByteArray() As Byte
ReDim sizeArray(0 To UBound(ByteArrays))
For i = 0 To UBound(ByteArrays)
sizeArray(i) = UBound(ByteArrays(i))
Next
startIndex = 0
ReDim Buffer(WorksheetFunction.Sum(sizeArray) + UBound(sizeArray))
For i = 0 To UBound(ByteArrays)
ByteArray = ByteArrays(i)
CopyMemory Buffer(startIndex), ByteArray(0), UBound(ByteArray) + 1
startIndex = startIndex + UBound(ByteArray) + 1
Next
JoinBytesArray = Buffer
End Function
Private Function Sum(ByVal IntegerArray As Variant) As Long
Dim i As Integer
For i = 0 To UBound(IntegerArray)
Sum = Sum + Val(IntegerArray(i))
Next
'// Range.Application.WorksheetFunction.Sum
End Function
- 이전글[vba] Variant 초기화(Erase) 21.08.28
- 다음글[vba] FolderCheck 함수를 이용한 폴더 생성 21.08.09
댓글목록
등록된 댓글이 없습니다.