Code
Public Function ShiftSArray(pArray() As String, pStartIndex As Long, pEndIndex As Long, pShiftCount As Long) As String()
'Function
'   Used to shift all elements down 1 space in an array.
'Parameters
'   pArray (String()) = The array to be shifted.
'   pStartIndex (Long) = The index to begin shifting.
'   pEndIndex (Long) = The index to stop shifting.
'   pShiftCount (Long) = The number of elements to shift.
'Return (String())
'   Returns the specified array with all elements shifted.
'   Only elements between pStartIndex and pEndIndex are shifted.
'   Elements are shifted pShiftCount elements up or down, depending on whether
'       pShiftCount is positive or negative.
'   If pShiftCount is positive, elements are shifted to higher-numbered positions.
'   If pShiftCount is negative, elements are shifted to lower-numbered positions.
'   If pShiftCount is zero, functions returns the specified array (pArray) unchanged.
'   If pArray is empty, function always returns an empty String array.
'Entry Conditions
'   The specified array must already contain enough elements to perform the shift
'       or this function will crash. Even if shifting elements in a negative direction,
'       if you attempt to move any of the shifted elements outside the array,
'       the function will crash.
'   If pStartIndex is greater than pEndIndex, the function will return pArray unchanged.
'   If pStartIndex is equal to pEndIndex, then only 1 element will be shifted.
'   If pStartIndex or pEndIndex are outside the bounds of the array, the function will crash.
'Notes
'   This function works with non-zero-based arrays.
'Version History
'   1.0 7/5/2003 Tested
'---

'Initiate Variables
Dim C As Long 'counter
Dim R() As String 'return buffer

'Preload the return buffer
R = pArray

'Our specified shift count is positive, loop backward
If pShiftCount > 0 Then

    'Loop though all the elements to be shifted, backwards
    For C = pEndIndex To pStartIndex Step -1
        R(C + pShiftCount) = R(C)
    Next C

'Our specified shift count is negative, loop forward
ElseIf pShiftCount < 0 Then

    'Loop though all the elements to be shifted
    For C = pStartIndex To pEndIndex
        R(C + pShiftCount) = R(C)
    Next C

End If

'Return the result
ShiftSArray = R

End Function


The Captian
Today they call you "crazy". Tomorrow they call you "ahead of your time."
Global Skywatch Learn about Chemtrails - You're breathing them now!
OnlyTheBestHerbs.com World-class supplements
Mercury Talk Why you are sick.
OneUp Domains Domains, Hosting, Email
1-800-358-4278 (U.S. & Canada)