Hi, I've been trying to develop a simple calculator, using class, methods, then I'm trying to develop into the main form but somehow I get frustrated and I've erased the code many times, because I'm doubting how to finish it, then this is what I have done. Take a look. I want to do it using only one "TextBox.Text".
Note: I have 3 months programing on Languages, and I really want to learn.
public class Calculator
{
public double Sum(double Variable1,double Variable2){
double ResultSum;
return ResultSum = Variable1 + Variable2;
}
public double Div(double Variable1, double Variable2){
double ResultaDiv;
return ResultaDiv = Variable1 / Variable2;
}
public double Subtra(double Variable1, double Variable2){
double ResultSubtra;
return ResultSubtra = Variable1 - Variable2;
}
public double Mult(double Variable1, double Variable2){
double ResulMult;
return ResulMult = Variable1 * Variable2;
}
}
}
----------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------
public partial class MainForm : Form
{
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void Button7Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "7"; // forget this part if you want.
}
void Button8Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "8";
}
void Button11Click(object sender, EventArgs e) // This a an operator "/"
{
}
}
}
Loading

Javeed M ShaikhPosted Apr 11, 2013, 4:56 PM
Freddy AbreuPosted Apr 12, 2013, 3:30 PM
Javeed M ShaikhPosted Apr 12, 2013, 10:59 AM
Freddy AbreuPosted Apr 12, 2013, 10:53 AM
Freddy AbreuPosted Apr 11, 2013, 4:37 PM
Javeed M ShaikhPosted Apr 11, 2013, 4:23 PM
correct me if I am wrong:
1. User enters a number in a textbox , textbox text is 1
2. then the user enters the operator, textbox text is 1+
3. then the user enters another number, textbox text is 1+1
4. user presses the = button, the label value is 2
5. user clicks the textbox again, so erase previous value since calculation is done.
is this correct?
Freddy AbreuPosted Apr 11, 2013, 3:25 PM
Javeed M ShaikhPosted Apr 11, 2013, 3:14 PM
What is your idea about using one text box, can you give me an example, is it like in the textbox user will type 1+1 and then click a button and the output will be displayed on a label next to it ?
Freddy AbreuPosted Apr 11, 2013, 2:43 PM
Satyapriya NayakPosted Apr 11, 2013, 12:14 PM