For...Next Statement

Relevant for: GUI actions, scripted GUI components, and function libraries

A For...Next loop instructs UFT to perform one or more statements a specified number of times. It has the following syntax:

For counter = start to end [Step step]
	statement
Next

Item

Description

counter

The variable used as a counter for the number of iterations.

start

The start number of the counter.

end

The last number of the counter.

step

The number to increment at the end of each loop.
Default = 1.
Optional.

statement

A statement, or series of statements, to be performed during the loop.

Example: In the following example, UFT calculates the factorial value of the number of passengers using the For statement:

passengers = Browser("Mercury Tours").Page("Find Flights").WebEdit("numPassengers").GetROProperty("value")
total = 1
For i=1 To passengers
    total = total * i
Next
MsgBox "!" & passengers & "=" & total