strongm,
I do not ever recall seing a prohibition aginst exititng an "If" (block) statement " ... without ending it ... ". I believe that it is - in fact - the recommended process for exiting some Loops. There are everal examples of this in Ms. Documentation, Here is one - taken from the VB 4 "Programmer's Guide:
Exiting a Control Structure
The Exit statement allows you to exit directly from a For loop, Do Loop, Sub procedure or Function Procedure. the syntax for the Exit Statement is simple: Exit For can appear as many times as needed insidea a For loop and Exit Do can appear as many times as needed insidea a Do loop:
For counter = start To end [Step increment]
statementblock
[Exit For]
statementblock
Next [counter[, counter] [,...]
Do [{While | Until} condition]
statementblock
Exit Do
statementblock
Loop
[Exit For and Exit Do are useful because sometimes it's appropiate to quit a loop immediately, without performing any further iterations or statements within the loop. For example, in the previous example that printed thn fontscommon to both the Screen and the Printer, the code continues to compare Printer fonts aginst a given Scree font even when a match has already been found with an earlier Printer font. A more efficient version would exit the loop as soon as a match is found:
Private Sun Form_Click()
Dim SFont, PFont
[tab]For Each SFont in Screen.Fonts()
[tab][tab]For Each PFont in Printer.Fonts()
[tab][tab][tab]If SFont = PFont Then
[tab][tab][tab][tab]Print SFont
[tab][tab][tab][tab]Exit For
[tab][tab][tab]End If
[tab][tab]Next PFont
[tab]Next SFont
End Sub
This procedure - given as an example of the 'proper' use of the Exit [For | Do] statement violates the thread arguments aginst the use of several variations of the single in / single out theme.
I am completely unsure of where this new variation on the 'rule' comes from. I AM completly sure it is entirely mis-guided. Even in those 'days of yore' (Yourdon et. al.), there was a recognition [/]AND ACCEPTANCE of the simple reality that 'the rules' were NOT universal. Including or convolouting code to just satisfy a ideal of form/format was not then (and in MY OPINION) should not NOW be a reason to avoid perfectly good instructions.
MichaelRed
mred@att.net
There is never time to do it right but there is always time to do it over