Timothy Madison

Timothy Madison

  • NA
  • 3
  • 13.9k

Trying to use Math.Pow method but having issues

Feb 14 2011 8:58 PM
I am an IT Student, creating a Loan Calculator in Visual Studio C# for an assignment in which I am required to use the Math.Pow method. However, I am having issues with it.

Getting the following error:

Error    1    'System.Windows.Forms.TextBox' does not contain a definition for 'CurrentValue' and no extension method 'CurrentValue' accepting a first argument of type 'System.Windows.Forms.TextBox' could be found (are you missing a using directive or an assembly reference?)   

Here is the code (.CurrentValue, .Value, and intTerm are underlined in the code with the error above showing for all three). Any assistance would be greatly appreciated. Thank you.

private void btnCalc_Click(object sender, EventArgs e)
        {
           
            {
                CalcLoanPayment();
            }

        }
        private void CalcLoanPayment()
        {
            int intTerm = 0;
            double dblPayment = 0;
            double dblCost = 0;

            double dblBalance = (double)txtBalance.CurrentValue;                   // price of total mortgage
            double dblRate = (double)txtRate.Value / 100;                               // calculate interest from 100%
            int intTerm = (int)(txtTerm.Value * 12);                                  // monthly term


            dblPayment = dblBalance * (Math.Pow((1 + dblRate / 12), intTerm) * dblRate) / (12 * (Math.Pow((1 + dblRate / 12), intTerm) - 1));

            dblCost = dblPayment * intTerm - dblBalance;

            lblPayment.Text = dblPayment.ToString("c");
        }

Answers (2)