Download Manual BasicMaker 2008
Transcript
For Each ... Next (statement) For Each Element In Group [Commands] [Exit For] [Commands] Next [Element] Executes a group of commands for all elements of a field or a collection. Element is a variable of type Variant (for arrays) or Object (for collections) that successively takes on the values of the individual elements from Group. For Each ... Next cannot be used with arrays of user-defined types. See also: For ... Next, Exit, section "Arrays", section "Using collections" Example: Sub Main Dim z(1 To 4) As Double z(1) = 1.11 z(2) = 2.22 z(3) = 3.33 z(4) = 4.44 For Each v In z Print v Next v End Sub For ... Next (statement) For Counter = InitialValue To FinalValue [Step StepSize] [Commands] [Exit For] [Commands] Next [Counter] Executes a group of commands in a loop. Counter is the counter variable that is increased by the value indicated in StepSize at each iteration. InitialValue is the initial value for Counter. FinalValue is the final value for Counter. StepSize is the step value. If it is omitted, the step value is 1. In the first iteration, Counter assumes the value of InitialValue. At each additional iteration, StepSize is added to the value of Counter. The loop execution will end as soon as FinalValue is exceeded. See also: For Each ... Next, Exit, section "Flow control" Example: Sub Main Dim x, y, z For x = 1 To 3 For y = 1 To 3 For z = 1 To 3 Print z, y, x Next z Next y Next x End Sub Manual BasicMaker 2008 Commands and functions from A to Z • 293