+ Reply to Thread
Results 1 to 2 of 2

Better for general use, IF or CASE?

  1. #1
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Better for general use, IF or CASE?

    Hi... I'm about to embark on a new project here at work, and as I understand it from the cocktail napkin requirements, I'm going to be doing a lot of calculations based on user input to a form I'll set up. I've been reading a bit about using CASE statements. I'm already pretty comfortable with using multiple IF's using global variables and am wondering if CASE statements are a better choice. Seems like they basically do the same thing... am I missing something?

    Thanks for your valued input, as always!

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Better for general use, IF or CASE?

    You would think that If/ElseIf/EndIf and Case statements would generate the same code, but I've heard that the former is more efficient.

    Even so, I'd opt for Case statement for readability. Arrange the cases from most likely to least likely if possible (equally true for If/ElseIf/EndIf).
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

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