"PeterB" <pe***@data.se> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
For i = 1 To iSz \ chunk
If Not Response.IsClientConnected Then Exit For
Response.BinaryWrite adoStream.Read(chunk)
Next
What does "For" stand for that is after "Then Exit" (Then Exit For)?
"For" stands for the [innermost] "For" Loop within which it appears.
"Exit For" instructs VB to "drop out" of a loop, continuing with the
next statement after the corresponding "Next".
(It's a nice[r] way of doing a Goto out of a loop).
Isn't End If missing in that statement?
No. This is the single-line form of If, which does not require a
matching End If, and, as you've discovered, it's damnably confusing.
I would /much/ prefer to see :
For i = 1 To iSz \ chunk
If Not Response.IsClientConnected Then
Exit For
End If
Response.BinaryWrite adoStream.Read(chunk)
Next
I thought about this as well :
For i = 1 To iSz \ chunk
If Response.IsClientConnected Then
Response.BinaryWrite adoStream.Read(chunk)
End If
Next
which /looks/ cleaner still, but if the loop executes a *lot* of
times and the client gets disconnected on one of the early iterations,
you're wasting a whole load of processor time doing all the /other/
iterations unnecessarily.
HTH,
Phill W.