Visual Basic 2005 for Programmers (2nd Edition)
5.1. Introduction
In this chapter and the next, we present the theory and principles of structured programming with control statementsimportant in building and manipulating objects. In this chapter, we introduce Visual Basic's If...Then, If...Then...Else, While, Do While...Loop and Do Until...Loop control statements, five of the building blocks that allow programmers to specify the logic required for methods to perform their tasks. We devote a portion of the chapter (and Chapters 6 and 8) to further developing the GradeBook class introduced in Chapter 4. In particular, we add a method to the GradeBook class that uses control statements to calculate the average of a set of student grades. Another example demonstrates how to combine control statements by "stacking" and "nesting" to solve a particular problem. You will notice that some examples use classes and a test module to demonstrate a concept, while others use only a module. When it does not make sense to create a reusable class to demonstrate a simple concept, we write the code in the Main method of a module. Throughout most of the chapter we use console applications to demonstrate new programming techniques. We devote one section to enhancing the Windows application you created in Chapter 2 to include your own Visual Basic code. |