# While Wend cycle

**URL:** <https://forum.xojo.com/t/while-wend-cycle/86578>\
**Category:** Windows\
**Created:** [September 24, 2025, 9:46am UTC](https://forum.xojo.com/t/while-wend-cycle/86578 "2025-09-24T09:46:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GUERINO\_IANDIORIO](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/e68b1a/32.png) [@GUERINO\_IANDIORIO](https://forum.xojo.com/u/GUERINO_IANDIORIO)\
**Post date:** [September 24, 2025, 9:46am UTC](https://forum.xojo.com/t/while-wend-cycle/86578/1 "2025-09-24T09:46:21Z")

</div>

Hi,

I don’t understand why this loop exits immediately on the first turn and doesn’t wait for the value to be equal to 4.

mycount=1  
while mycount \< 4

IF Mycondition then  
messagebox(“Mycondition verified !”)  
gestione1.ShowModal  
else  
messagebox(“Mycondition NOT verified !”)  
mycount = mycount + 1  
end if

wend

messagebox(“The OTP verification attempt limit has been exceeded. The procedure will be closed.”)  
self.close

Thanks

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [September 24, 2025, 9:49am UTC](https://forum.xojo.com/t/while-wend-cycle/86578/2 "2025-09-24T09:49:28Z")

</div>

> [@GUERINO\_IANDIORIO](#):
>
> mycount=1  
> while mycount \< 4

Your code is correctly executed; mycount is less than 4… because it is 1.

---

<div class="post-metadata">

**Author:** ![GUERINO\_IANDIORIO](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/e68b1a/32.png) [@GUERINO\_IANDIORIO](https://forum.xojo.com/u/GUERINO_IANDIORIO)\
**Post date:** [September 24, 2025, 10:11am UTC](https://forum.xojo.com/t/while-wend-cycle/86578/3 "2025-09-24T10:11:58Z")

</div>

Hi Emile,

he actually goes around three times and then comes out. I misinterpreted it.  
Thanks

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [September 24, 2025, 10:32am UTC](https://forum.xojo.com/t/while-wend-cycle/86578/4 "2025-09-24T10:32:44Z")

</div>

Longtime ago, I had troubles with Less Than (\<) and Greater Than (\>); a friend helped me and the troubles goes away since then. 😉  
But sometimes I made errors with Boolean; I do not try to understand, I swap the code and it works !

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [September 24, 2025, 12:48pm UTC](https://forum.xojo.com/t/while-wend-cycle/86578/5 "2025-09-24T12:48:05Z")

</div>

I would have expected something more like this:

Ask for an OTP.

If it is incorrect, ask again. keep asking until 4 tries

Then decide if the right answer or 4 tries happened first

(I am assuming that gestione1.ShowModal is where how check the MyCondition)

> [@GUERINO\_IANDIORIO](#):
>
> `gestione1.ShowModal`
> 
> `mycount=1`  
> `while Mycondition = false and mycount < 4`  
> `gestione1.ShowModal`  
> `mycount = mycount + 1`  
> `wend`
> 
> `if mycount = 4 then `
> 
> `messagebox(“The OTP verification attempt limit has been exceeded. The procedure will be closed.”)`  
> `self.close`
> 
> `else`
> 
> `messagebox(“Mycondition verified !”)`
> 
> `end if`
