Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Pro VB 6 For 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 Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 12th, 2009, 09:31 PM
Authorized User
Join Date: Mar 2008
Location: , , .
Posts: 20
Thanks: 1
Thanked 0 Times in 0 Posts
Question 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
____________bFileMissing = True
________End If
________bFileMissing = True
____End If
____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..
Reply With Quote
  #2 (permalink)  
Old October 13th, 2009, 12:09 AM
Authorized User
Join Date: Mar 2009
Posts: 49
Thanks: 0
Thanked 8 Times in 8 Posts

see my answer to this Q in... http://www.xtremevbtalk.com/showthread.php?t=311144

Good Luck
Reply With Quote
  #3 (permalink)  
Old October 18th, 2009, 02:17 AM
Registered User
Join Date: Oct 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

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.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
puzzle for date ranges navjot C# 1 October 16th, 2008 02:21 PM
A small puzzle marianeeli C++ Programming 9 September 5th, 2006 12:02 AM
DataAdapter.Update puzzle wirerider ASP.NET 2.0 Basics 1 August 1st, 2006 06:57 PM
Join table puzzle... vanjamier SQL Language 1 November 26th, 2004 04:43 AM
Crossword Puzzle Euler C++ Programming 4 October 19th, 2004 02:08 AM

All times are GMT -4. The time now is 06:36 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.