System.FormatException: 'Indatasträngen hade ett felaktigt format.'
tja,
håller att lära mig C# i koden får jag detta fel "System.FormatException: 'Indatasträngen hade ett felaktigt format." som jag förstår och inte vet hur jag ska lösa det
public partial class frmInvoiceTotal : Form
{
public frmInvoiceTotal()
{
InitializeComponent();
}
int numberOfInvoices = 0;
decimal totalOfInvoices = 0m;
decimal invoiceAverage = 0m;
private void BtnCalculate_Click(object sender, EventArgs e)
{
decimal subtotal = Convert.ToDecimal(txtEnterSubtotal.Text);
decimal discountPercent = .25m;
decimal discountAmount = Math.Round(subtotal * discountPercent, 2);
decimal invoiceTotal = subtotal - discountAmount;
txtSubtotal.Text = subtotal.ToString("c");
txtDiscountPercent.Text = discountPercent.ToString("p1");
txtDiscountAmount.Text = discountAmount.ToString("c");
txtTotal.Text = invoiceTotal.ToString("c");
numberOfInvoices++;
totalOfInvoices += invoiceTotal;
invoiceAverage = totalOfInvoices / numberOfInvoices;
txtNumberOfInvoices.Text = numberOfInvoices.ToString();
txtTotalOfInvoices.Text = totalOfInvoices.ToString("c");
txtInvoiceAverage.Text = invoiceAverage.ToString("c");
txtEnterSubtotal.Text = "";
txtEnterSubtotal.Focus();
}