Loop Through an Array

Is
For i = LBound(arr) To UBound(arr)
the best way to iterate through and array in VBScript? What is the point of asking for LBound? Isn't that always 0 (zero)?

While uncommon, it is possible for LBound to not always be 0.

So, why not user FOR EACH? That way you don't need to care what the LBound and UBound are.
Dim x, y, z
x = Array(1, 2, 3)

For Each y In x
    z = DoSomethingWith(y)
Next


Array ASP Loop For Each


Back To Top
© 1998 - 2017 psacake.com | My3C's

Version 7.2 | Advertise on this site