Note that there are some explanatory texts on larger screens.

plurals
  1. PONo extension method with windows forms
    text
    copied!<p>The problem is in</p> <pre><code>num1 = Convert.ToDecimal(this.withBox.Text); </code></pre> <p>of <code>bankAccount()</code></p> <p>I am attempting to make it where you can type any decimal into the withBox textbox and when you click the button it will give you the amount in the <code>aMtBox</code>. I am unsure of what I am doing wrong.</p> <p>Is gives me this error, but I do not know why?</p> <p>What I am wanting, is for num1 to equal whatever I type into my withBox. That is my end goal.</p> <pre><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 WindowsFormsApplication2 { public partial class Form1 : Form { BankAccount a = new BankAccount(); public Form1() { InitializeComponent(); decimal iBa = 300.00m; this.aMtBox.Text = iBa.ToString(); } private void dep_Click(object sender, EventArgs e) { try { decimal num1 = 0.00m; decimal iBa = 300.00m; num1 = Convert.ToDecimal(this.depBox.Text); decimal total = num1 + iBa; this.aMtBox.Text = total.ToString(); } catch { MessageBox.Show("ERROR", "Oops, this isn't good!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } public void withdrawl_Click(object sender, EventArgs e) { this.aMtBox.Text = a.Balance.ToString(); } public class BankAccount { decimal balance; decimal iBa; decimal num1; public decimal Balance { get { return balance; } } public decimal IBa { get { return iBa; } } public decimal Num1 { get { return num1; } } public BankAccount() { iBa = 300.00m; num1 = Convert.ToDecimal(this.withBox.Text); balance = iBa - num1; } } private void withBox_TextChanged(object sender, EventArgs e) { } } </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload