Since the For Next loop will be used to especially optimized the counter variable must be of the
Integer type.
Example:
For
i=1
To
If i>a Then
a=i
End If
a=a-1
Next
For
i=1
To
If
i>3
a=i
End If
a=a-1
Next
In this location please note again that arrays are in any case zero based. A For Next loop should
thus rather run from
Exit Instruction
An Exit instruction will leave the loop and the program execution starts with the next instruction after
the For loop.
Example:
For
i=1
To
If
i=6
Exit
End If
Next
5.3.6.4
Goto
Even though it should be avoided within structured programming languages, it is still possible with
goto to jump to a label within a procedure. In order to mark a label the command word Lab is set in
front of the label name.
' For loop with goto will realize
Sub main()
Dim a As Integer
a=0
Lab label1
© 2008 Conrad Electronic
10
10
Step
3
'Increment i in steps of 3
Then
0
through 9.
10
Then
Compiler
118
Need help?
Do you have a question about the C-Control Pro Mega Series and is the answer not in the manual?
Questions and answers