Visual Basic and Visual FoxPro For Next loops

VBA

For, Step, Exit For, Next

VFP

For, Step, Loop, Exit, Next, EndFor

Common Syntax Notes

This is another structure where there is very similar syntax in the two languages.

For i = 1 To 10
  ? i
Next i

FoxPro used to end the structure with an EndFor but Visual FoxPro now accepts the VBA syntax Next clause as an alternative:

Both languages also have a For Each structure for working with arrays and collections.

Use the Loop keyword to skip the rest of the code in the FoxPro loop and return immediately to the test in the For statement. Use the Exit command to break out of the loop and execute the statement following Next.

Loops  |  Language index  |  Procedures

Related Items

VFP and VBA.

The Visual FoxPro and Visual Basic for Applications languages are similar but there are annoying differences between them.

Read More

Text delimiters in VBA and VFP.

Visual Basic for Applications and Visual FoxPro delimiters for strings.

Read More

Text concatenation in VBA and VFP

Visual Basic for Applications and Visual FoxPro operators to concatenate text.

Read More

Text substrings in VBA and VFP

Visual Basic for Applications and Visual FoxPro functions to extract substrings from within a string of text

Read More

Trimming text in VBA and VFP

Visual Basic for Applications and Visual FoxPro functions to trim leading and trailing spaces from string of text

Read More