|
'Const ARRAY_CUT_FROMTOP = 0
'Const ARRAY_CUT_FROMBOTTOM = 1
Function ARRAY_CutElements(ByRef aToCut, ByVal intCount, ByVal constDirection) Dim aRemainder() Dim aCut() Dim intLB, intUB Dim i intLB = LBound(aToCut) intUB = UBound(aToCut) If intCount >= intUB + 1 Then ARRAY_CutElements = aToCut aToCut = Null Else ReDim aRemainder(intUB - intCount) ReDim aCut(intCount - 1) Select Case constDirection Case ARRAY_CUT_FROMTOP For i = intLB To intUB If i <= intCount - 1 Then aCut(i) = aToCut(i) Else aRemainder(i - intCount) = aToCut(i) End If Next Case ARRAY_CUT_FROMBOTTOM For i = intLB To intUB If i < intUB - intCount Then aRemainder(i) = aToCut(i) Else aCut(i - intUB + intCount) = aToCut(i) End If Next End Select aToCut = aRemainder ARRAY_CutElements = aCut End If End Function
|