B4A - Ch1 - Section 3 - Loops

Being able to properly perform a loop is yet another one of the primary features of any programming language that everyone should be familiar with.

For Loop


Dim i As Int
For i = 1 to 5
  'Code here
Next

 

Do While Loop


Dim ndx as Int
ndx = 0
Do While ndx < 11
  If 1 = 5 Then Exit    ' Exit our loop
  If 2 = 6 Then Return  ' Exit the Subroutine
  ndx = ndx + 1
Loop

 

Do Until Loop


Dim ndx as Int
ndx = 0
Do Until ndx = 11
  If 1 = 5 Then Exit    ' Exit our loop
  If 2 = 6 Then Return  ' Exit the Subroutine
  ndx = ndx + 1
Loop