Other Tips
Sponsored Link

Handle dynamic array
2013/01/06
  This is an example for Handling dynamic array in VBScript
Option Explicit

Dim Item, Items(), Messages

Push Items, "sample"
Push Items, "script"

Messages = ""
For Each Item In Items
    Messages = Messages & Item & " "
Next

MsgBox Messages

Sub Push(arr,elm)
    Dim i,tmp
    
    i = 0
    If IsArray(arr) Then
        For Each tmp In arr
            i = 1
            Exit For
        Next

        If i=1 Then
            Redim Preserve arr(Ubound(arr)+1)
        Else
            Redim arr(0)
        End If
    Else
        arr = Array(0)
    End If

    If IsObject(elm) Then
        Set arr(Ubound(arr)) = elm
    Else
        arr(Ubound(arr)) = elm
    End If
End Sub
Matched Content
 
Tweet