|
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long) Public Sub CopyArrayINT(ArraySource() As Integer, _ ArrayDest() As Integer, Optional ByVal iStart As Integer, _ Optional ByVal iEnd As Integer, _ Optional ByVal iInsertAt As Integer) Dim iNElements As Integer Dim iIndiceD As Integer, iIndiceS As Integer 'Controlla il valore del primo indice dell'array sorgente iIndiceS = LBound(ArraySource) If iStart > iIndiceS Then iIndiceS = iStart iIndiceD = LBound(ArrayDest) 'Controlla se e' stata specificata un elemento diverso dal 'primo dove inserire gli elementi da copiare If iInsertAt > iIndiceD Then iIndiceD = iInsertAt 'Numero di elementi da copiare (max quelli contenuti 'nell'array 'di destinazione) If iEnd = 0 Then iEnd = UBound(ArrayDest) iNElements = iEnd - iIndiceS + 1 CopyMemory ArrayDest(iIndiceD), ArraySource(iIndiceS), _ Len(ArrayDest(iIndiceD)) * iNElements End Sub |