As you saw in this chapter, Visual Basic .NET requires you to play by certain rules when writing programs. Some rules concern the way in which you create names for variables . Other rules must be followed when creating program statements. Collectively, the rules that you must follow are called the syntax rules for Visual Basic .NET. You know that in this assignment statement:
Age = 34
the equal sign ( = ) is the assignment operator and that it requires two operands. When operands and operators are combined together correctly, they form an expression. One or more expressions form a program statement. By arranging program statements in a very specific way, you can create a program that you can run to solve a specific problem. You can see this relationship is Figure 4.8.
Figure 4.8. Progressing from operands and operators to a Visual Basic .NET program.
You can write a program that abides by the syntax rules but still doesn't work properly. You can do the same thing in English. For example, an English sentence usually has a noun and a verb. This sentence :
The dog meowed.
has a noun and a verb, and it abides by the syntax rules of English, but it doesn't make sense because dogs don't meow. This type of error is called a semantic error. In such errors, the syntax rules are followed properly, but the words (or operands, in the case of programming languages) are used out of context. You can write programs in Visual Basic .NET that have semantic errors. The bad news is that Visual Basic .NET may not be equipped to catch such errors.
You can also write programs that don't have either syntax or semantic errors but still produce incorrect results. Such errors are most often caused by problems with the design of the program, or its logic.
Any error in a program is called a bug, and the process of correcting and removing program errors is called debugging the program.
As you write programs throughout this book, I actually ask you to introduce bugs into them. I do this because it gives you some familiarity with how Visual Basic .NET handles program bugs. It also helps you become a better detective in isolating and correcting other bugs that might creep into your programs. Seeing Visual Basic .NET error messages under controlled circumstances is a valuable learning tool.