Android Question For loop not going for Next

janitra

Member
Hi
I have a code like this

B4X: Copy
If ..... Then
For i = 0 to List.Size - 1
    If ..... Then
        If .... Then
            //do something
        Else
            //do something
        End If
    Else
        If .... Then
            //do something
        Else
            //do something
        End If
    End If
Next
End If

The List length is 2.

The problem is, whenever the "if" inside loop is done, the loop will break.
The "i" is still equal to 0, but the loop break.
 
To less informations for us to help you.

The "i" is still equal to 0, but the loop break.
Upload a small example which shows the Issue.
 
Upvote 0
The first thing to check is whether you are doing something that is changing the List size within the loop and so forcing an early exit.
Or quite commonly a nested loop using the same variable (i in this case) as an index. Although that would change the value of i, but worth a check.
 
Upvote 0
Back
Top