Visual Basic for Applications/Errors

This lesson introduces debugging and error handling.

Objectives and Skills
Objectives and skills for debugging and error handling include:
 * Using debugging tools to suspend and step through code
 * Using debugging tools to examine code while it is running
 * Incorporating error-handling code to respond to run-time errors

Readings

 * 1)  Debugging
 * 2)  Error handling
 * 3) Microsoft: On Error Statement

Activities
In these activities you will create macros that use input validation and error handling to catch and respond to runtime errors. Your macros should include Option Explicit, Dim, InputBox, MsgBox, titles on the dialog boxes, an icon on the message box, and use appropriate data types for your variables.
 * 1) Age Calculations
 * 2) Create a macro that asks the user how old they are in years.  Then ask the user if they would like to know how old they are in months, days, hours, or seconds. Use an If/ElseIf/Else or Select Case statement to display their approximate age in the selected time frame.
 * 3) Use the IsNumeric function to validate user input for the numeric entry.
 * 4) Use Else or Case Else to validate user input for the selected time frame.
 * 5) Add error handling to handle any runtime errors that could occur in the macro.
 * 6) Temperature Conversion
 * 7) Create a macro that asks the user if they would like to convert Fahrenheit to Celsius or Celsius to Fahrenheit. Use an If/ElseIf/Else or Select Case statement to determine their selection and then gather the appropriate input and calculate and display the converted temperature.
 * 8) Use Else or Case Else to validate user input for the selected conversion type.
 * 9) Use the IsNumeric function to validate user input for the numeric entry.
 * 10) Add error handling to handle any runtime errors that could occur in the macro.
 * 11) Area Calculations
 * 12) Create a macro that asks the user what shape they would like to calculate the area for. Use an If/ElseIf/Else or Select Case statement to determine their selection and then gather the appropriate input and calculate and display the area of the shape.
 * 13) Use Else or Case Else to validate user input for the selected shape type.
 * 14) Use the IsNumeric function to validate user input for any numeric entries.
 * 15) Add error handling to handle any runtime errors that could occur in the macro.
 * 16) Average Calculation
 * 17) Create a macro that asks the user to enter grade scores. Start by asking the user how many scores they would like to enter. Then use a loop to request each score and add it to a total. Finally, calculate and display the average for the entered scores.
 * 18) Use the IsNumeric function to validate user input for each numeric entry.
 * 19) Add error handling to handle any runtime errors that could occur during the calculations.