how to make an simple calculator in C#..???simpple calculator which contains addition,multiplication,subtraction and division methods..
how to make an simple calculator in C#
Page 1 of 16 Replies - 52352 Views - Last Post: 30 December 2010 - 03:37 AM
Replies To: how to make an simple calculator in C#
#2
Re: how to make an simple calculator in C#
Posted 16 October 2010 - 06:08 AM
Have you made any effort to make the calculator yet. We cant just give you the code you need to show that you have made an attempt first.
#3
Re: how to make an simple calculator in C#
Posted 16 October 2010 - 06:18 AM
#4
Re: how to make an simple calculator in C#
Posted 16 October 2010 - 06:22 AM
I can help you with this if you like, but do you know how to use visual studio? Do you know how to make an application and add buttons etc? Your post was abit vague.
#5
Re: how to make an simple calculator in C#
Posted 16 October 2010 - 06:26 AM
I think this should help you out 
http://www.dreaminco...ulator-in-c%23/
edit:
Bummer, someone was faster than I was
If your planning to make a GUI calculator in Visual Studio, you should find some literature (or sources) about that first
http://www.dreaminco...ulator-in-c%23/
edit:
Bummer, someone was faster than I was
If your planning to make a GUI calculator in Visual Studio, you should find some literature (or sources) about that first
This post has been edited by karabasf: 16 October 2010 - 06:28 AM
#6
Re: how to make an simple calculator in C#
Posted 16 October 2010 - 09:02 AM
#7 Guest_Niveditha*
Re: how to make an simple calculator in C#
Posted 30 December 2010 - 03:37 AM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace work1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private double num1;
private double num2;
private string cal;
private bool inputstatus = true;
private void button1_Click(object sender, EventArgs e)
{
if (inputstatus)
{
if (textBox1.Text.Length >= 1)
{
textBox1.Text += button1.Text;
}
}
}
private void button2_Click(object sender, EventArgs e)
{
if (inputstatus)
{
textBox1.Text += button2.Text;
}
else
{
textBox1.Text = button2.Text;
inputstatus = true;
}
}
private void button3_Click(object sender, EventArgs e)
{
if (inputstatus)
{
textBox1.Text += button3.Text;
}
else
{
textBox1.Text = button3.Text;
inputstatus = true;
}
}
private void button4_Click(object sender, EventArgs e)
{
if (inputstatus)
{
textBox1.Text += button4.Text;
}
else
{
textBox1.Text = button4.Text;
inputstatus = true;
}
}
private void button5_Click(object sender, EventArgs e)
{
if (inputstatus)
{
textBox1.Text += button5.Text;
}
else
{
textBox1.Text = button5.Text;
inputstatus = true;
}
}
private void button6_Click(object sender, EventArgs e)
{
if (inputstatus)
{
textBox1.Text += button6.Text;
}
else
{
textBox1.Text = button6.Text;
inputstatus = true;
}
}
private void button7_Click(object sender, EventArgs e)
{
if (inputstatus)
{
textBox1.Text += button7.Text;
}
else
{
textBox1.Text = button7.Text;
inputstatus = true;
}
}
private void button8_Click(object sender, EventArgs e)
{
if (inputstatus)
{
textBox1.Text += button8.Text;
}
else
{
textBox1.Text = button8.Text;
inputstatus = true;
}
}
private void button9_Click(object sender, EventArgs e)
{
if (inputstatus)
{
textBox1.Text += button9.Text;
}
else
{
textBox1.Text = button9.Text;
inputstatus = true;
}
}
private void button10_Click(object sender, EventArgs e)
{
if (inputstatus)
{
textBox1.Text += button10.Text;
}
else
{
textBox1.Text = button10.Text;
inputstatus = true;
}
}
private void button11_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length != 0)
{
num1 = System.Double.Parse(textBox1.Text);
result();
cal = "+";
}
}
private void button12_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length != 0)
{
num1 = System.Double.Parse(textBox1.Text);
result();
cal = "-";
}
}
private void button13_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length != 0)
{
num1 = System.Double.Parse(textBox1.Text);
result();
cal = "*";
}
}
private void button14_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length != 0)
{
num1 = System.Double.Parse(textBox1.Text);
result();
cal = "/";
}
}
private void button16_Click(object sender, EventArgs e)
{
result();
cal = string.Empty;
}
private void button15_Click(object sender, EventArgs e)
{
textBox1.Text = string.Empty;
num1 = 0;
num2 = 0;
cal = string.Empty;
}
private void result()
{
num2 = System.Double.Parse(textBox1.Text);
switch (cal)
{
case "+":
num1 = num1 + num2;
break;
case "-":
num1 = num1 - num2;
break;
case "*":
num1 = num1 * num2;
break;
case "/":
num1 = num1 / num2;
break;
}
textBox1.Text = num1.ToString();
inputstatus = false;
}
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.Copy();
}
private void pasteCtrlVToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.Paste();
}
private void cutCtrlXToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.Cut();
}
}
}
MOD EDIT: When posting code...USE CODE TAGS!!!
Attached image(s)
This post has been edited by JackOfAllTrades: 30 December 2010 - 05:26 AM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote






|