ASP.NET: List Controls and Validation

We are going to modify our existing Future Value program to make it more difficult for the user to enter incorrect data. Do the following:

  • Monthly Investment: no change.
  • Annual Interest Rate:Change the Annual Interest Rate to a drop-down list that has values from 0.50% through 7.00% in .50% increments. Express the text as percent values, but store the value as a decimal (but note that the value field is still a string and it must be converted into a double).
  • Number of Years: Change Number of Years to a drop-down list that has values from 5 to 45 in 5-year increments.
  • Payment at the Beginning of the Month: Add a check box that indicates whether the payment is at the beginning or the end of the month.
  • Add a validation control to the Monthly Investment text box. The value must be a positive number that is at least $1 and no more than $5,000. Display an appropriate error message to the right of the text box if an out-of-range error occurs. The user should not be allowed to input a non-numeric value.
  • Calculate Button: The Calculate button should perform the same way as before.
  • Clear Button: The Clear button should set the Monthly Investment to 0, the Annual Interest Rate to 5.0%, the Number of Years to 40, clear the check box, and set the Future Value to $0.00.

The image below has the correct answer for the given data. If you turn the check box off, you get $68,006.08. Note that your answer will be a negative number. Whether you change this to a positive number or not is up to you. Negative numbers will show up with parentheses around them when formatted as currency (below).

You can either compute your answer using a loop or you can use the FV function. Note that to use the FV function you must:

  • Right-click on the project name (second line under the Solution Explorer) and choose “add reference”.
  • Then click on the “.NET” tab and click on Microsoft Visual Basic and click on OK.
  • Then add the "using Microsoft.VisualBasic;" statement at the top of your C# file.
  • To access all of the VB financial functions, you must prefix them with the class name "Financial" (e.g. Financial.FV)
  • To use the FV function to compute the future value with payments either at the end of the month or the beginning of the month, you will have to use the enumerated data type DueDate. You may want to create a variable of type DueDate, although it is not necessary. You can just use the two enumerated values.

What to hand in

Zip your entire project and put it in the drop box.