This method is decreasing value of textBox1 for amount inserted in textBox2. If there isn't enough "money" in textBox1, excessing amount should be taken from textBox3. At the end, method should update textboxes to new values, but only textBox2 is cleared, and textBox1 and textBox3 remain unchanged. Can anyone tell me why textBox1.text = Account.toString()
doesn't assign textbox value to value from variable Account
and textBox3.text = Savings.toString()
doesn't assign textbox value to value from variable Savings
?
public void Debit(decimal amount)
{
decimal Account = Convert.ToDecimal(textBox1.Text);
decimal Savings = Convert.ToDecimal(textBox3.Text);
if ((Account + Savings) < amount)
if (Overdrawn != null)
Owerdrawn(this, new OverdrawnEventArgs (Account, amount));
else if (Account >= amount)
Account -= amount;
else {
amount -= Account;
Account = 0m;
Savings -= amount;
}
textBox1.Text = Account.ToString();
textBox2.Clear();
textBox3.Text = Savings.ToString();
}
textBox1.Text = String.Format("N0", Account)
? – Eisenhorn