Mortgage Problem w/ Error Checking
Modify the program developed in the last assignment to incorporate error checking.
There are two places where you should check for errors:
If there is an error in any of the user input you force the user to re-enter the data and you bypass both reading values from the form into variables and performing calculations. If there is an error in any of the data used in a calculation you react by warning the user and continuing with the calculations if the data is merely questionable, or by using an alternative set of calculations if the data is unusable.
Errors in User Input:
For example, if a user fails to enter a value in a field (i.e., Text property is equal to "") but still hits the calculate button, display a message box on the screen asking them to provide the required input and return the focus to the unfilled text box using the Focus method. You can obtain the value entered in a text box by using the Val function.
Another error that you should detect is string data rather than numeric data. For example, if the user enters "Sixty Thousand" into the Loan Amount field you should detect that by using the IsNumeric function and forcing them to re-enter the data.
Further, a loan amount, percent rate, or loan duration that is negative is also invalid and must be detected.
Note that in this particular implementation the loan duration must be an integer number, so your program should detect invalid entries such as a 0.75 year loan duration.
In all fields you should check to be sure that user entries are reasonable.
This next part is more difficult. The calculations on which this program is based require that the user enter an interest rate in the form 12 rather than 0.12. You can handle this by checking to be sure that the interest rate is an integer or greater than 1, but that limits the program's usability. That approach prevents the program from calculating a loan based on 0% interest rate or an interest rate like 12.5%. A better solution is to generate an error and force the user to re-enter the value if the interest rate is negative, and to simply detect a non-integer interest rate BETWEEN 0 and 1 and warn the user of a potential problem without forcing them to re-enter anything. Check how your program reacts to such issues as a 0.25% rate, a 0% rate, percentage rates such as 12.5% rates, etc. Compare your program to the demo, and be sure to note the difference between message boxes that display an error and those that display a warning. Your message boxes should resemble those in the demo.
Errors in Calculations:
One of the basic problems that you look for when writing error checking routines is conditions that can adversely affect mathematical calculations. One of the most obvious is divide by zero. As you recall from your basic Math days, you can't divide by zero. Our first step is to look closely at our calculations to see if any of them offer the potential for a divide by zero condition. In the mortgage program there are two places where division takes place, and both must be examined to insure that a divide by zero does not occur.
At the very least, include the following error checking:
Refer to the sample solution for Program 1 for proper program formatting.
There is a help page in case you get desperate.