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

Chapter 6 - Using Decision Structures - Part 2

By , About.com Guide

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!

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 Decision Structures - Part 2

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

All rights reserved.