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

Chapter 6 - Using Decision Structures - Part 2

By Dan Mabbutt, About.com

3 of 3

Bonus Page: The IIF Function is another decision structure you can use

IIF

IIF

One little known decision structure in VB.NET wasn't covered in the book - IIF. No, I didn't fat-finger the keyboard - that's the way it's spelled and it was part of the VB 6 language as well.

If you have the right requirement in your program, this structure can be a convenient way to code it with fewer keystrokes. It works as shown in the illustration.

Notice that this is a Function ... not a native VB.NET command. That does make a difference. Because it's a function, it returns a value. The expression is evaluated and either TruePart or FalsePart is returned as the value of the function.

You can read about IIF at MSDN- Microsoft's authoritative reference page.

Now it's your turn! Decide to write some great code!

Index: Chapter 6 - Using Decision Structures - Part 2

  1. If-Then-Else compared with Select Case
  2. The Select Case Structure
  3. Bonus Page: The IIF Function is another decision structure you can use

3 of 3

Explore Visual Basic

More from About.com

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB.NET
  5. Using Decision Structures - Part 2

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

All rights reserved.