using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Calculator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private Boolean lastCharIsSymbol { get; set; }
int number;
bool add = false;
bool subtract = false;
bool multiply = false;
bool divide = false;
private void button0_Click(object sender, EventArgs e)
{
number = 0;
textBox1.Text += number.ToString();
lastCharIsSymbol = false;
}
private void button1_Click(object sender, EventArgs e)
{
number = 1;
textBox1.Text += number.ToString();
lastCharIsSymbol = false;
}
private void button2_Click(object sender, EventArgs e)
{
number = 2;
textBox1.Text += number.ToString();
lastCharIsSymbol = false;
}
private void button3_Click(object sender, EventArgs e)
{
number = 3;
textBox1.Text += number.ToString();
lastCharIsSymbol = false;
}
private void button4_Click(object sender, EventArgs e)
{
number = 4;
textBox1.Text += number.ToString();
lastCharIsSymbol = false;
}
private void button5_Click(object sender, EventArgs e)
{
number = 5;
textBox1.Text += number.ToString();
lastCharIsSymbol = false;
}
private void button6_Click(object sender, EventArgs e)
{
number = 6;
textBox1.Text += number.ToString();
lastCharIsSymbol = false;
}
private void button7_Click(object sender, EventArgs e)
{
number = 7;
textBox1.Text += number.ToString();
lastCharIsSymbol = false;
}
private void button8_Click(object sender, EventArgs e)
{
number = 8;
textBox1.Text += number.ToString();
lastCharIsSymbol = false;
}
private void button9_Click(object sender, EventArgs e)
{
number = 9;
textBox1.Text += number.ToString();
lastCharIsSymbol = false;
}
private void buttonPlus_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || lastCharIsSymbol)
return;
else
{
add = true;
textBox1.Text += " + ";
lastCharIsSymbol = true;
}
}
private void buttonMinus_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || lastCharIsSymbol)
return;
else
{
subtract = true;
textBox1.Text += " - ";
lastCharIsSymbol = true;
}
}
private void buttonMultiply_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || lastCharIsSymbol)
return;
else
{
multiply = true;
textBox1.Text += " * ";
lastCharIsSymbol = true;
}
}
private void buttonDivide_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || lastCharIsSymbol)
return;
else
{
divide = true;
textBox1.Text += " / ";
lastCharIsSymbol = true;
}
}
private void buttonEquals_Click(object sender, EventArgs e)
{
if (add)
{
}
if (subtract)
{
}
if (multiply)
{
}
if (divide)
{
}
}
private void buttonClear_Click(object sender, EventArgs e)
{
textBox1.Text = String.Empty;
}
}
}
[/source]
What I want to do, is be able to use more than 2 numbers together in the one textbox.
For example, I want to be able to do like, 14 + 86 - 24, etc.
How do I go about doing this? If I had 2 textboxes it would seemingly be easy storing the values placed in them in 2 seperate ints. But since I want to be able to use more than 2 numbers how do I do this?
And for the record, this is a self-teaching project, not schoolwork.
Sorry if this is simple stuff/straight forward, my brains bunched up lately.