Your question is a bit vague.
B4X is categorised as a procedure-oriented language.
There are many ways to generate conditional or unconditional programme branches, many of which are also known from other BASIC dialects.
IF THEN
IIF THEN
SELECT CASE
(to name just three)
The only difference is that you first assign a procedural code to a control element or an event (programme start) and execute the corresponding actions in this procedure. Depending on the result, another procedure is then called and so on...
The previously feared spaghetti code generated by GOTO statements can also occur here (even without GOTO). This usually happens if the programme is not preceded by a well thought-out construct, i.e. if you are simply programming at random.
And yes, you have to use flags for leaving a loop.
Here a (dirty hack) example for leaving a loop:
Do While event
If condition Then Exit
Loop
condition could be a flag, often a boolean variable is used (true/false)
don't forget to reset the boolean variable afterwards