*.dannyg

VBScript Array

Jul
20

Pretty neat script I wrote that allowing preserving an array by cloning it.

Function AddToArray(ArrayToClone, ValueToAdd)
Dim a, tempArray
    On Error Resume Next
    ReDim tempArray(UBound(ArrayToClone) + 1)
    If Err.Number = 0 Then
        For a = LBound(ArrayToClone) To UBound(ArrayToClone)
            tempArray(a) = ArrayToClone(a)       
        Next
    ElseIf Err.Number = 13 Then       
        Err.Clear
        ReDim tempArray(0)
    Else
        WScript.Echo Err.Number
    End If
    tempArray(UBound(tempArray)) = ValueToAdd       
    AddToArray = tempArray
End Function

Technorati Tags: ,

Leave a Reply