Results 1 to 6 of 6

Speed/Efficiency for If-Else Construct

Threaded View

  1. #1
    Registered User
    Join Date
    03-31-2009
    Location
    Auburn Alabama
    MS-Off Ver
    Microsoft Office Excel 2007 (Windows)
    Posts
    99

    Speed/Efficiency for If-Else Construct

    Hello,

    My question is about the If-Else Construct.

    I often write If-Else statements that require an action be taken only if something is true. If that something is false, no action is to be taken.

    My question is, how do you code "no action".

    The following is what i usually code:

    If Variable < 2 Then
        Variable = Variable + 1
    Else
        Variable = Variable
    As you see above, when false, I usually just assign the variable the value it already has. That's because I want nothing to happen if the result is false.

    But isn't that a waste of time for my program? Am i not just giving my processor one more thing to do for no reason. Slowing down my program with unnecessary assignments?

    If so, what are my alternatives? Is there a common programming strategy that all programmers adhere to in this situation? I mean, do I just put nothing after the Else Construct (except for a maybe a comment noting the nothingness was intentional)? Hmmm...

    Thanks for any help! Trying to be efficient here
    Last edited by CrazyFileMaker; 04-21-2009 at 04:54 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1