| Visual Basic 2008 » Chapter 11 |
Using Decision StructuresIn Chapter 8, "Creating Code Procedures," you learned to separate code into multiple procedures so that they can be called in any order required. This goes a long way in organizing code, but you still need a way to selectively execute code procedures or groups of statements within a procedure. You use decision-making techniques to accomplish this. Decision-making constructs are coding structures that enable you to execute or omit code based on a condition, such as the value of a variable. Visual Basic includes two constructs that enable you to make any type of branching decision you can think of: If...Then...Else and Select Case. In this chapter, you'll learn how to use the decision constructs provided by Visual Basic to perform robust yet efficient decisions in Visual Basic code. In addition, you'll learn how to use the GoTo statement to redirect code within a procedure. You'll probably create decision constructs in every application you build, so the quicker you master these skills, the easier it will be to create robust applications.
Chapter 11.1: The If Statement The simplest way to make a decision in a Visual Basic .NET program is to use the If statement. Read more...
Whenever you want to test a single variable for multiple values, the Case structure provides a flexible and powerful solution. Read more...
This section, you’ll take a look at the two main types of loops available in Visual Basic. Read more... |