'********************************************************************

'*

'* Function ResizeOnAdd

'*

'*   Author: NetworkAdminKB.com

'*  Created: 2006-01-07

'* Modified: 2006-01-07

'*

'* Purpose: Return an array with the specified value added and

'*            with one more element in the size of the array.

'*

'*   Input: aryAny = The array to have the element added to

'*          anyVar = The variable to add to the array.

'*      blnVerbose = A Boolean indicating if error messages should

'*                     be displayed.

'*                      True  = Display Error Messages

'*                      False = Do NOT Display Error Messages

'*        

'*  Output: Returns the array with the specified value added at

'*            the end of the array.  This results in the size of

'*            the array increasing by 1.

'*          Return the original variable if the array passed is

'*            not actually an array.

'*

'*   Notes: This function adds the elements to the end of the array.

'*

'********************************************************************

Function ResizeOnAdd(ByVal aryAny, ByVal anyVar, ByVal blnVerbose)

  'Version: 1.0 2006-01-07

  Dim intUBound, intIndex

 

  If IsEmpty(aryAny) Then

    ReDim aryAny(0)

    aryAny(0) = anyVar

  Else  

    If IsArray(aryAny) Then

      intUBound = UBound(aryAny)

      ReDim Preserve aryAny(intUBound + 1)

      aryAny(intUBound + 1) = anyVar

    Else

      If blnVerbose Then

        Wscript.Echo "ResizeOnAdd", _

                     "Error: The aryAny parameter passed is not an array."

      End If 'blnVerbose

    End If 'IsArray(aryAny)

  End If 'IsEmpty(aryAny)

  ResizeOnAdd = aryAny

End Function 'ResizeOnAdd

Article ID: 415, Created On: 9/25/2011, Modified: 9/25/2011