Runtime errors

Run-time errors occur during program execution. The sources of these errors are many. For example, attempting to enter an invalid input such as a Currency value instead of an Integer, or to reference an incorrectly named range, or to open a workbook file which does not exist, or even to divide something by zero (0). All of these would precipitate a run-time error. Note that the background colour of the line where the run-time error occurs is yellow. This indicates that the program execution has stopped at that line -called a line break.

Normally a run-time error message dialog box would accompany the error, an example of which is shown in Figure 8.2. Note that the dialog box includes four option buttons:

♦ Continue. In this example the button is greyed out, meaning that continuing with the run is not an option since the error prevents this from b eing possible.

♦ The End option is not going to help solve the problem, and is there for those who know what the problem is and want to quickly close the dialog box.

♦ Debug will display the offending line on a yellow background.

Figure 8.2 An example of a run-time error message dialog box

Help will give context sensitive Help, though this is generally better suited to experienced programmers because of its technical depth.

Logical errors are not accompanied with error messages, because these errors occur from the program doing something different to that of its intended meaning. In other words, these arise from program semantics. Unfortunately, this is not as easy as it sounds because a program cannot ascertain what a user's intentions were. For example, suppose that a programmer inadvertently used an incorrect formula during the writing of a macro; how would Excel know what the intended formula was? The only way to be sure that a program works properly is to apply a rigorous test and debugging regime. The following section shows how logical errors can be eradicated by using a test and debugging methodology. The test methodology will give confidence in the program correctness, and the debugging methods will provide the facilities to ensure that the job is being done in the correct way.

0 0

Post a comment