Note that there are some explanatory texts on larger screens.

plurals
  1. POwindows forms, methods, and buttons
    primarykey
    data
    text
    <p>I am testing out a bank account on windows forms. Something easy to start with. In my <code>dep_Click</code> method I have a way where if i click it does the code I wanted in the <code>aMtBox</code>. I wanted to expand further and attempted to make a BankAccount class with some properties, etc. I used my <code>withdrawl_Click</code> method for this as an attempt to do so. Everything I see looks like it would be okay in a console application, except I have no idea how to call the method in the <code>withdrawl_Click</code>; that is, I was it be able to use my code I wrote.</p> <p>Is the code completely wrong and something is different in windows forms applications? Or is there a concept I am/have not understood. Please explain and make this clear to me.</p> <p><strong>EDIT</strong>: I updated my code, however it is still giving me an error about needing a return type in the <code>withDrawl</code> method near the bottom. Still unsure.</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(iBa, num1); public Form1() { InitializeComponent(); decimal iBa = 300.00m; // needs fixed to be more universal 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); } } private void withdrawl_Click(object sender, EventArgs e) { } public class BankAccount { decimal iBa; decimal num1; decimal withT; public decimal IBa { get { return iBa; } } public decimal Num1 { get { return num1; } } public decimal Witht { get { return withT; } } public withDrawl(decimal n, decimal s ) { iBa = n; num1 = s; withT = iBa - num1; } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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