Next Loop

G

Guest

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?
 
G

Guest

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:
 
B

Bob Phillips

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)
 
G

Guest

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.
 
B

Bob Phillips

There is.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
G

Guest

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.
 
B

Bob Phillips

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)
 
D

Dana DeLouis

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top