O'Reilly logo

Visual Basic 2010 Unleashed by Alessandro Del Sole

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Conditional Code Blocks

If..Then..Else

The If..Then..Else is the most classical block for conditionally executing actions. An If evaluates an expression as True or False and according to this allows specifying actions to take. Listing 4.7 shows an example.

Listing 4.7 Demonstrating the If..Then..Else Block

image

If checks if the condition is True; if so, it takes the specified action. Of course you can also specify to evaluate a condition for False (for example, If something = False Then). You can also use an ElseIf to delimit the condition evaluation. If no expression satisfies the condition, the Else statement provides an action that will be executed ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required