private void DepositButton_Click(object sender, EventArgs e) { decimal deposit; if (decimal.TryParse(DepositTextBox.Text, out deposit)) { myAccount.Deposit(deposit); //calculate the account balance when deposit money DepositTextBox.Text = ""; BalanceResult.Text = myAccount.GetBalance.ToString("C"); //Output the result } else { MessageBox.Show("The entered deposit is invalide - Please retry"); DepositTextBox.SelectAll(); } }
private void DepositButton_Click(object sender, EventArgs e) { decimal amount; // convert the amount to a decimal if (decimal.TryParse(DepositTextBox.Text, out amount)) { // deposit the amount into the account account.deposit(amount); // display the new balance BalanceLabel.Text = account.Balance.ToString(); // clear the box DepositTextBox.Clear(); } }