Chapter 7. Controlling the Flow of Your Program

In this chapter

Understanding If Statements

Using Select Case

Structuring Your Code Logically

Working with Loops

Exercise: The Pop-Up Eliminator

From Here . . .

Two of the fundamental strengths of computers are their capabilities to execute instructions quickly and to make decisions precisely. In this chapter, you will learn how to take advantage of these capabilities in two very important ways: through the use of decision-making techniques and the use of loops, which allow portions of code to run a controlled number of times.

In the last chapter, you learned about a class of code statements known as assignment statements, which are used to set and modify the values of variables. Another group of statements is important for handling more complex tasks. These statements are known collectively as control statements. Without control statements, your program would start at the first line of code and proceed line by line until the last line was reached, at which point the program would stop.

One type of control statement is the decision statement.This statement is used to control the execution of parts of your program, based on conditions that exist at the time the statement is encountered. The two basic types of decision statements are If statements and Select Case statements. The other major type of control statement is the loop. You use loops to perform repetitive tasks in your program. Three main types of loops are supported by Visual Basic: counter loops, conditional loops, and enumerator loops.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.9.164