J janitra Member Jan 22, 2021 #1 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.
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.
DonManfred Expert Licensed User Longtime User Jan 22, 2021 #2 To less informations for us to help you. janitra said: The "i" is still equal to 0, but the loop break. Click to expand... Upload a small example which shows the Issue. Upvote 0
To less informations for us to help you. janitra said: The "i" is still equal to 0, but the loop break. Click to expand... Upload a small example which shows the Issue.
agraham Expert Licensed User Longtime User Jan 22, 2021 #3 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. 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.
stevel05 Expert Licensed User Longtime User Jan 22, 2021 #4 agraham said: 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. Click to expand... 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
agraham said: 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. Click to expand... 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.