-
Need Help
I am writting a C# GUI program that will calculate a car payment. I keep getting an error on one line of code. All text boxes are correctly identified in the code.
Here is the code:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace CarGUI
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double CarPrice, Total;
double CreditScore;
double MonthlyPayment;
double InterestRate;
double PaymentPlan;
CarPrice = Convert.ToDouble(textBox1);
PaymentPlan = Convert.ToDouble(textBox3);
CreditScore = Convert.ToDouble(textBox2);
if (CreditScore <= 450)
InterestRate = .12;
else if (CreditScore >= 451 && CreditScore >= 600)
InterestRate = .10;
else if (CreditScore >= 601 && CreditScore >= 700)
InterestRate = .07;
else
InterestRate = .02;
MonthlyPayment = (CarPrice / PaymentPlan) * InterestRate;
label4.Text = String.Format ("Car Price {0}", CarPrice.ToString("C"));
label5.Text = String.Format("with a credit score of {0}", CreditScore.ToString);
label6.Text = String.Format("making your payments {0}", MonthlyPayment.ToString("C"));
}
}
}
Label5 line is the error that I get.
Thanks for looking and helping.
DK
-
Re: Need Help
I have surrounded your code snippet with [code] and [/code] tags to preserve the indentation. Welcome to the forum!
-
Re: Need Help
ToString() is a method. You just need to adjust the line to:
Code:
label5.Text = String.Format("with a credit score of {0}", CreditScore.ToString());
This was a simple problem, but for more complicated problems, it's very helpful to know the specific error message. It's WAY easier to debug if the error message is known.
Hope that helps!