title: Bank Account Program Deposit Button is not working
body: <p>The program is a GUI that has two tabs. On the first tab there are four textboxes for name, id, age, and account balance. There is also a button on this tab that will add the account to a combobox on the second tab. On the second tab, there is the combobox and four textboxes for name, id, age, and balance. when i select a name from the combobox the four textboxes automatically fill in with their information. The problem i'm running into is that i have to have a withdraw and a deposit button that the user can enter an amount and have it either subtracted or added to the balance in the textbox. I have some example code for the withdraw button that someone already helped me out with.  Can anyone tell me why it isn't changing the balance when i hit the button?</p>
  
  <pre><code>class BankAccount
  {
      //attributes
      public string accountID;
      public string customerName;
      public int customerAge;
      public double balance;
      public const double DEFAULT_BALANCE = 500.00;
  
      //construct
      public BankAccount()
      {
      }
  
      public BankAccount(string anID, string aName, int anAge, double aBalance)
      {
          accountID = anID;
          customerName = aName;
          customerAge = anAge;
          balance = aBalance;
          if (aBalance == 0)
          {
              balance = DEFAULT_BALANCE;
          }
          else
          {
              balance = aBalance;
          }
      }
  
      public BankAccount(string anID, string aName, int anAge)
      {
          accountID = anID;
          customerName = aName;
          customerAge = anAge;
          balance = DEFAULT_BALANCE;
      }
  
  
  
  
  
  
      //accessors
      public void SetID(string anID)
      {
          accountID = anID;
      }
  
      public void SetName(string aName)
      {
          customerName = aName;
      }
  
      public void SetAge(int anAge)
      {
          customerAge = anAge;
      }
  
      public void SetBalance(double aBalance)
      {
          balance = aBalance;
      }
  
      public string GetID()
      {
          return accountID;
      }
  
      public string GetName()
      {
          return customerName;
      }
  
      public int GetAge()
      {
          return customerAge;
      }
  
      public double GetBalance()
      {
          return balance;
      }
  
  
  }
  
  }
  </code></pre>
  
  <p>and here's the form</p>
  
  <pre><code> public partial class Form1 : Form
   {
  
      private List&lt;BankAccount&gt; account = new List&lt;BankAccount&gt;();
  
      public Form1()
      {
          InitializeComponent();
      }
  
  
  
      private void btnAddAccount_Click(object sender, EventArgs e)
      {
          BankAccount aBankAccount = new BankAccount(txtAccountID.Text, txtName.Text,
              int.Parse(txtAge.Text), double.Parse(txtBalance.Text));
  
          account.Add(aBankAccount);
          AddToComboBox();
          ClearText();
  
  
      }
  
      private void AddToComboBox()
      {
          cboAccount.Items.Clear();
          foreach (BankAccount person in account)
          {
  
              cboAccount.Items.Add(person.GetName());
  
  
          }
  
  
      }
      private void ClearText()
      {
          txtName.Clear();
          txtAccountID.Clear();
          txtBalance.Clear();
          txtAge.Clear();
          txtAccountID.Focus();
  
  
      }
  
      private void cboAccount_SelectedIndexChanged(object sender, EventArgs e)
      {
          txtNameTab2.Text = account[cboAccount.SelectedIndex].customerName;
          txtAgeTab2.Text = account[cboAccount.SelectedIndex].customerAge.ToString();
          txtAccountIDTab2.Text = account[cboAccount.SelectedIndex].accountID.ToString();
          txtBalanceTab2.Text = account[cboAccount.SelectedIndex].balance.ToString();
      }
  
  
  
      private void btnWithdraw_Click(object sender, EventArgs e)
      {
  
          double amount = 0;
  
          if (double.TryParse(txtWithdraw.Text, out amount))
          {
              if (amount &gt; 0)
              {
                  BankAccount currentAccount = account[cboAccount.SelectedIndex];
                  double currentBalance = currentAccount.GetBalance();
                  double amountLeft = currentBalance - amount;
  
                  if (amountLeft &gt;= 0)
                  {
                      currentAccount.SetBalance(amountLeft);
                      txtBalanceTab2.Text = amountLeft.ToString("c");
                  }
                  else
                  {
                      MessageBox.Show("You don't have enough money!");
                  }
  
  
  
              }
  
          }
      }
  
  
  }
  }
  </code></pre>