1. Download the free trial version

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

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

  1. wes58

    wes58 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.. :)
  3. wes58

    wes58 Member Licensed User

    Thanks for that.
  4. shaxboz

    shaxboz Member Licensed User

    Hi! How can I count down with for...next?
  5. DonManfred

    DonManfred Well-Known Member Licensed User

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

    eps Well-Known Member Licensed User

Share This Page

Loading...