You will deal with three major categories of errors in your Visual Basic applications:
Some errors are so blatant that Visual Basic will refuse to compile your application. Generally, such errors are due to simple syntax issues that can be corrected with a few keystrokes. But you can also enable features in your program that will increase the number of errors recognized by the compiler. For instance, if you set
Option Strict to
On in your application or source code files, implicit narrowing conversions will generate compile-time errors.
' ----- Assume: Option Strict On Dim bigData As Long = 5& Dim smallData As Integer ' ----- The next line will not compile. smallData = bigData
Visual Studio 2008 includes features that help you locate and resolve compile-time errors. Such errors are marked with a "blue squiggle" below the offending syntax. Some errors also prompt Visual Studio to display corrective options through a pop-up window, as shown in Figure 9-3.
Figure 9-3. Error correction options for a narrowing conversion
Runtime errors occur when a combination of data and code causes an invalid condition in what otherwise appears to be valid code. Such errors frequently occur when a user enters incorrect data into the application, but your own code can also generate runtime errors. Adequate checking of all incoming data will ...