1. Home
  2. Computing & Technology
  3. Visual Basic

Chapter 7 - Using Loops and Timers - Part 2

By , About.com Guide

4 of 4

My Answer - Assignment from the previous lesson

In Chapter 6, should If or Select Case be used?

In the previous lesson, I promised my answer to a question about whether to use an If ... ElseIf ... End If decision structure or a Select Case structure to calculate TaxDue.

"You will find that you get exactly the same answer with either code. So ... Assignment: Which One Should You Use?"

Here are my thoughts on the subject.

Fundamentally, it's a matter of your preferred programming style. The bottom line is getting the program to work correctly and efficiently and both styles do that. But my preferred programming style is Select Case. I find it easier to read and understand than the If structure. To my mind, it's easier to see exactly which statements are executed for every condition.

Frequent About Visual Basic contributor, Peter Zilahy Ingerman, PhD adds this reasoning, "Select Case makes writing multiple Or conditions simpler, so that if one begins by having a zillion separate Case statements, and one discovers that there are really only three or four actions, collapsing the Cases under a Select Case is a *whole* lot easier than rewriting the If-ElseIf-...-End structure."

Explore Visual Basic
By Category
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB.NET
  5. Using Loops and Timers - Part 2

©2009 About.com, a part of The New York Times Company.

All rights reserved.