For...Each Statement
A For...Each loop instructs QuickTest to perform one or more statements for each element in an array or an object collection. It has the following syntax:
For Each item In array
statement
Next
Item Description
item A variable representing the element in the array.
array The name of the array.
statement A statement, or series of statements, to be performed during the loop.
The following example uses a For...Each loop to display each of the values in an array:
MyArray = Array("one","two","three","four","five")
For Each element In MyArray
msgbox element
Next
Note: During a run session, if a For Each statement iterates on the Parameter Definitions collection, the run may fail if the collection was retrieved directly before using the For Each statement. To prevent this, use other VBScript loop statements, such as For or While.
No comments:
Post a Comment