Pro VB 6For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Pro VB 6 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
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 13th, 2009 at 12:18 AM.
set bFileMissing=true only when it satisfies the condition.
as bFileMissing=false is initialized prior to the execution of "nested if" filter, no need to set it again to false.