Re: how do people feel about exit function from loop



"Robert Morley" <rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:uDBiXAlzHHA.312@xxxxxxxxxxxxxxxxxxxxxxx
But the same logic applies...if you're concerned about having one way out
of a function, it follows that you will likely be the type who also likes
one way out of a loop (for most of the same reasons), thus wanting to
avoid Exit.

Not really. The logic behind having one way out of a function is that you
can have cleanup code to release references etc (which has mostly been
eliminated with high level languages). For a loop there is no chance to have
cleanup code except after it, so the cleanup code will be called anyway. The
one-way-out is by going to the line of code after the loop.

In a language with try/catch/finally block this is all moot anyway because
you can have your exit function and have one way out, eg

Private Sub ABC()
dim rs as new recordset
rs.open "Blah"
Try
While not rs.eof
if rs!Something = SomethingElse then exit sub
rs.movenext
Wend
finally
rs.close
End Try

Michael


.



Relevant Pages

  • Re: Looping procedure calls userform; how to exit loop (via userform button)?
    ... Set a public property called say Cancel in the userform module/ Have your ... exit button set it to True, ... I need to break the loop. ... > Private Sub 1 ...
    (microsoft.public.excel.programming)
  • Not accessible ERROR!
    ... Private Sub Calendar1_DayRender(ByVal sender As Object, ... exit the for loop ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: how do people feel about exit function from loop
    ... In some cases, though, you'll want variables altered inside the loop to be ... Exit For and similar constructs become largely undesirable, ... cleanup code will be more likely to happen identically regardless ... Private Sub ABC() ...
    (microsoft.public.vb.general.discussion)
  • Re: Infinite Loops and Explicit Exits
    ... > CS> One of these proposals relaxes the current restriction that an EXIT ... > termination of the loop is not visible at that point. ... > terminating condition is visible in that context. ... > You now want to allow this remote procedure, ...
    (comp.lang.cobol)
  • Re: Houston-related rants was Re: forced merges/inside lane merges/AASHTO "tapered merges"
    ... >> Are you sure about the North Loop and I-45? ... >> in particular the westbound exit for Fondren/Gessner. ... How could HCTRA put an exit ramp for eastbound ... and the West Houston Center Blvd exit still shows Old Westheimer ...
    (misc.transport.road)