Program 2: 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 reenter 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 reenter 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.
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 reenter the value if the interest rate is negative, and to simply detect a noninteger interest rate and warn the user of a potential problem without forcing them to reenter 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.
In the formula for calculating factor, we must be sure that the divisor, decIntPerPayment, cannot equal 0. What conditions could make decIntPerPayment equal 0? The answer is a 0% interest rate. We have already established, however, that a 0% interest rate is acceptable. How do we avoid a divide by zero then? We check for a decIntPerPayment not equal to zero, and in that case we calculate factor as specified. If decIntPerPayment is equal to zero, then we cannot use the formula that was provided to calculate factor. Instead, we must set factor equal to totalPayments in order for the subsequent calculations to work correctly. I figured that out by looking closely at the calculations.
The next formula that could potentially be subject to a divide by zero problem is the paySize formula. The divisor in this case is factor. Test the value of factor to be sure it is not equal to zero before calculating paySize. If factor is equal to 0, it is not apparent how to react so we can simply set the paySize equal to the loanAmount, since we are unable to calculate a valid result.
At the very least, include the following error checking:
Check each field to be sure that a value has been entered. 
Check each field to be sure that a numeric value has been entered. 
Check each field to be sure that a negative
value has not been entered or, in the case of the loan duration, that an
integer value greater than 1 has been entered. Here are some
sample tests for an integer:

Check to be sure that all formulas result in valid values, i.e., check for potential problems like division by zero. 
Sample frmMortgage:
Refer to the sample solution for Program 1 for proper program formatting.