Forum Discussion

Sreera's avatar
Occasional Contributor
6 years ago

Loop statements

How do I get my code to re-enter for loop after executing Exit For statement. Below is sample code   For i = 1 to x  if instr(x,"abc") Then     Exit For Else {statement} End if Next ...
  • tristaanogre's avatar
    6 years ago

    The whole point of the Exit statement for a for loop is to indicate that you have reached some sort of condition in the loop that you no longer need to continue looping.  This is true for any language, not just VB.


    So, if there is a special condition within the loop that you want to execute special code before you continue, what I would do is, rather than exit the loop, make "stmnt" a separate function and call that.  This way you can call stmnt within the loop and then, when stmnt is done, complete the loop.