121
Part II
Programming Fundamentals
In this part:
Chapter 5: Visual Basic Variables and Formulas, and the .NET Framework.... 123
Chapter 6: Using Decision Structures.................................... 159
Chapter 7: Using Loops and Timers..................................... 181
Chapter 8: Debugging Visual Basic Programs............................ 209
Chapter 9: Trapping Errors by Using Structured Error Handling............. 227
Chapter 10: Creating Modules and Procedures........................... 247
Chapter 11: Using Arrays to Manage Numeric and String Data............. 273
Chapter 12: Working with Collections................................... 297
Chapter 13: Exploring Text Files and String Processing.................... 313
In Part I, “Getting Started with Visual Basic 2010,” you learned how to create the user
interface of a Microsoft Visual Basic 2010 program and how to build and run a program
in the Microsoft Visual Studio 2010 development environment. In the nine chapters in Part II,
“Programming Fundamentals,” you’ll learn more about Visual Basic program code—the
statements and keywords that form the core of a Visual Basic program. You’ll learn how to
manage information within programs and control how your code is executed, and you’ll
learn how to use decision structures, loops, timers, arrays, collections, and text files. You’ll
also learn how to debug your programs and handle run-time errors if they occur. After you
complete Part II, you’ll be ready for more advanced topics, such as customizing the user
interface, database programming, and Web programming.
Table of Contents
Programming Fundamentals
Visual Basic Variables and Formulas, and the .NET Framework... 123
The Anatomy of a Visual Basic Program Statement...................... 123
Using Variables to Store Information.................................. 124
Setting Aside Space for Variables: The Dim Statement........ 124
Implicit Variable Declaration.................................... 126
Using Variables in a Program......................................... 127
Using a Variable to Store Input....................................... 130
Using a Variable for Output.......................................... 133
Working with Specific Data Types..................................... 135
Constants: Variables That Don’t Change.......................... 142
Working with Visual Basic Operators.................................. 143
Basic Math: The +, –, *, and / Operators.......................... 144
Using Advanced Operators: \, Mod, ^, and &.................... 147
Working with Math Methods in the .NET Framework.................... 152
One Step Further: Establishing Order of Precedence.................... 155
Using Parentheses in a Formula................................. 156
Chapter 5 Quick Reference........................................... 156