What is the best way to iterate through an array in Classic Asp VBScript? *

Question

Is:

For i = LBound(arr) To UBound(arr)

The best way?

What is the point in asking for LBound? Surely that is always 0 isn't it?

Answer

Why not use 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
< br > via < a class="StackLink" href=" http://stackoverflow.com/questions/2348/" >What is the best way to iterate through an array in Classic Asp VBScript?< /a>
Share on Google Plus

About Cinema Guy

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment