For ... Next, Do While... Loop

Discussion in 'Android Questions' started by wes58, Jan 5, 2011.

  1. wes58

    wes58 Active Member Licensed User

    I have the following sample code:

    How can I exit the loop if certain conditions are met. Normally you would use "Exit For" statement in For loop but it doesn't work here.
    I know I could change the value of i to max. value when I get into the "If... end if" code but I need to know the value of i that stopped the For loop in the rest of the code?
    I guess I could assign value of i inside "If ... end if" to another variable before changing it to max value but that complicates the code (unnecessary).
    The same is with While loop
  2. JesseW

    JesseW Active Member Licensed User

    It's not Exit For, it's just Exit in B4A. It exits the inner most loop, no matter the structure (ie. For Next, Do Loop, Sub, etc..) I ran across this myself.. :)
    Reinosoft likes this.
  3. wes58

    wes58 Active Member Licensed User

    Thanks for that.
  4. shaxboz

    shaxboz Member Licensed User

    Hi! How can I count down with
  5. DonManfred

    DonManfred Expert Licensed User

    For i = 100 To 0 Step -1
    ' do something
  6. eps

    eps Well-Known Member Licensed User