![]() |
Next Loop
If I am in a while or for loop and I have a statement like this:
if 1=1 then 'Go to next iteration of for loop or change cells and go back to top of while loop end if What is the syntax for continuing the loop at this point. Right now, I create spaghetti code by saying to goto a label like Goto NextLoop and then at the bottom of the loop right before the next or loop line, I have a line: NextLoop: But I want to avoid all this goto jumping. How do I do this? |
Next Loop
Provide details of BOTH what you want to do and the full code you have
tried. -- Don Guillett Microsoft MVP Excel SalesAid Software "Mike H." wrote in message ... If I am in a while or for loop and I have a statement like this: if 1=1 then 'Go to next iteration of for loop or change cells and go back to top of while loop end if What is the syntax for continuing the loop at this point. Right now, I create spaghetti code by saying to goto a label like Goto NextLoop and then at the bottom of the loop right before the next or loop line, I have a line: NextLoop: But I want to avoid all this goto jumping. How do I do this? |
Next Loop
Rather than use a go add an if
Do while if condition then end if loop "Mike H." wrote: If I am in a while or for loop and I have a statement like this: if 1=1 then 'Go to next iteration of for loop or change cells and go back to top of while loop end if What is the syntax for continuing the loop at this point. Right now, I create spaghetti code by saying to goto a label like Goto NextLoop and then at the bottom of the loop right before the next or loop line, I have a line: NextLoop: But I want to avoid all this goto jumping. How do I do this? |
Next Loop
Here is an example of a While Loop
Do While True Line Input #ff, Line If Line Like "*rofit Center Totals:*" Then GoTo OutofLoop End If If Len(Line) = 0 Then GoTo MoreLoop ElseIf Line Like "*lass Name(ID):*" Then GoTo MoreLoop end if 'additional code here if the above jumps did not jump me somewhere MoreLoop: Loop OutofLoop: |
Next Loop
Do While True
Line Input #ff, Line If Line Like "*rofit Center Totals:*" Then Exit Do End If If Not Len(Line) = 0 Then If Not Line Like "*lass Name(ID):*" Then 'additional code here End If End If Loop -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Mike H." wrote in message ... Here is an example of a While Loop Do While True Line Input #ff, Line If Line Like "*rofit Center Totals:*" Then GoTo OutofLoop End If If Len(Line) = 0 Then GoTo MoreLoop ElseIf Line Like "*lass Name(ID):*" Then GoTo MoreLoop end if 'additional code here if the above jumps did not jump me somewhere MoreLoop: Loop OutofLoop: |
Next Loop
That is what I was looking for:
Exit Do Is there also: Exit For? Thanks... |
Next Loop
I was having trouble with Boorlean if not... stuff before and thought maybe
it wasn't available in this language either. But I'll have to make sure i write it correctly then use it. Thanks. |
Next Loop
There is.
-- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Mike H." wrote in message ... That is what I was looking for: Exit Do Is there also: Exit For? Thanks... |
Next Loop
Is there any syntax like
continue for that would perform another iteration of the loop? Sometimes it is not always practical to have the if...then... to cause the loop to run or not. |
Next Loop
Why not? You can always wrap that code into a procedure and call that.
-- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Mike H." wrote in message ... Is there any syntax like continue for that would perform another iteration of the loop? Sometimes it is not always practical to have the if...then... to cause the loop to run or not. |
Next Loop
Do While True
Line Input #ff, Line May not apply here, but using EOF was commonly used back in the dark ages: Do While Not EOF(1) Line Input #1, x ' etc... Loop -- HTH Dana DeLouis "Mike H." wrote in message ... Here is an example of a While Loop Do While True Line Input #ff, Line If Line Like "*rofit Center Totals:*" Then GoTo OutofLoop End If If Len(Line) = 0 Then GoTo MoreLoop ElseIf Line Like "*lass Name(ID):*" Then GoTo MoreLoop end if 'additional code here if the above jumps did not jump me somewhere MoreLoop: Loop OutofLoop: |
All times are GMT +1. The time now is 12:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com