A little optimization puzzle
I think some of you may have learned how to make the following nested If more compact, maybe in an algorithms discussion in school or some such place. If so I'd like to learn the trick. It is an example of a situation I run into occasionally. Or, maybe the code cannot be further reduced and I'm looking for something needlessly. (The code works fine as is.) I had one person give me an incorrect reduction but I'm still curious to see if anyone can teach me something.
bFileMissing = False ' Initialize
If (CantFindFile(sName)) Then
____If bCheckOtherPlace Then
________Call SwitchLocation(sName)
________If (CantFindFile(sName)) Then
____________bFileMissing = False
________Else
____________bFileMissing = True
________End If
____Else
________bFileMissing = True
____End If
Else
____bFileMissing = False
End If
If bFileMissing Then MsgBox "Not Found"
(by the way, how do you overcome the whitespace eliminator and show indentation in examples without doing what I just did?)
Last edited by williamlove; October 12th, 2009 at 11:18 PM..
|