knowledgediarybd.com

Your Virtual Knowledge Campus

How to make a C sharp Calculator

java arrayC sharp calculator means the that calculator which is developed by C# language.C-sharp is a another powerful language among  all other programming languages.

Now a days A lot of important software are developed  by c-sharp language. C# mainly work on .NET Frame work and provides a strong security that’s why it’s popularity is increasing day by day.

Dear learner here,I will discuss & provide a  C-sharp program source code that act as a simple calculator.By this calculator you can addition,

subtraction, multiplication and division. I hope you will get pleasure by this simple calculator program and if you get pleasure than i will be satisfied.

How to make a C sharp calculator?

If you want to test or run you have to do some following task:

1. Microsoft Visual Stdio Version(8 or 10) Or Microsoft Visual Stdio v12

2. .Net Frame work 3.5 or 4

3.Open the Microsoft Visual Stdio & select the windows form application Like Below and Follow the Command written on the picture:

C# calculator code

4. Open project or Copy and past of the following code and save as that i provide on the above picture Like:program.cs,HKABIRCALCULATOR.cs

5. Finally From the top menu click debug button then click start without

Debugging.

6. Then you will see the C# calculator Interface Like:

csharp calculator icon

Program.cs code here:

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new HKABIRCALCULATOR());
}
}
}

HKABIRCALCULATOR.cs code here:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class HKABIRCALCULATOR : Form
{
public HKABIRCALCULATOR()
{
InitializeComponent();
}

private void button12_Click(object sender, EventArgs e)
{
textBox1.Clear();
}

private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + button1.Text;
}

private void button3_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + button3.Text;
}

private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + button2.Text;
}

private void button4_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + button4.Text;
}

private void button5_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + button5.Text;
}

private void button6_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + button6.Text;
}

private void button7_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + button7.Text;
}

private void button8_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + button8.Text;

}

private void button9_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + button9.Text;
}

private void button11_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + button11.Text;
}
double total1 = 0;
double total2 = 0;
bool plusbtn = false;
bool minusbtn = false;
bool mulbtn = false;
bool divbtn = false;

private void addbtn_Click(object sender, EventArgs e)
{
total1 = total1 + Double.Parse(textBox1.Text);
textBox1.Clear();
minusbtn = false;
plusbtn = true;
mulbtn = false;

}

private void subbtn_Click(object sender, EventArgs e)
{
total1 = Double.Parse(textBox1.Text) - total1;
textBox1.Clear();
minusbtn = true;
plusbtn = false;
mulbtn = false;

}

private void mulbtn_Click(object sender, EventArgs e)
{
total1 = 1;
total1 = total1 * Double.Parse(textBox1.Text);
textBox1.Clear();
minusbtn = false;
plusbtn = false;
mulbtn = true;
}

private void divbtn_Click(object sender, EventArgs e)
{
total1 = 0;
total1 = total1 + Double.Parse(textBox1.Text);
textBox1.Clear();
minusbtn = false;
plusbtn = false;
divbtn = true;
mulbtn = false;
}

private void equal_Click(object sender, EventArgs e)
{
if (plusbtn == true)
{
total2 = total1 + double.Parse(textBox1.Text);

}
else if (minusbtn == true)
{
total2 = total1 - double.Parse(textBox1.Text);
}
else if (mulbtn == true)
{
total2 = total1 * double.Parse(textBox1.Text);
}
else if (divbtn == true)
{
total2 = total1 / double.Parse(textBox1.Text);
}
textBox1.Text = total2.ToString();
total1 = 0;

}

private void button17_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + button17.Text;
}
}

}

 HKABIRCALCULATOR.Designer.cs code here:

namespace WindowsFormsApplication1
{
partial class HKABIRCALCULATOR
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HKABIRCALCULATOR));
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.button7 = new System.Windows.Forms.Button();
this.button8 = new System.Windows.Forms.Button();
this.button9 = new System.Windows.Forms.Button();
this.button10 = new System.Windows.Forms.Button();
this.button11 = new System.Windows.Forms.Button();
this.button12 = new System.Windows.Forms.Button();
this.button13 = new System.Windows.Forms.Button();
this.button14 = new System.Windows.Forms.Button();
this.button15 = new System.Windows.Forms.Button();
this.button16 = new System.Windows.Forms.Button();
this.button18 = new System.Windows.Forms.Button();
this.button17 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.BackColor = System.Drawing.SystemColors.Info;
this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox1.Cursor = System.Windows.Forms.Cursors.SizeNWSE;
this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBox1.Location = new System.Drawing.Point(12, 12);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(253, 38);
this.textBox1.TabIndex = 0;
this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// button1
//
this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button1.Location = new System.Drawing.Point(12, 208);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(46, 37);
this.button1.TabIndex = 1;
this.button1.Text = "1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button2.Location = new System.Drawing.Point(81, 208);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(46, 37);
this.button2.TabIndex = 2;
this.button2.Text = "2";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button3.Location = new System.Drawing.Point(148, 208);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(46, 37);
this.button3.TabIndex = 3;
this.button3.Text = "3";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button4.Location = new System.Drawing.Point(12, 156);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(46, 37);
this.button4.TabIndex = 4;
this.button4.Text = "4";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button5
//
this.button5.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button5.Location = new System.Drawing.Point(81, 157);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(46, 37);
this.button5.TabIndex = 5;
this.button5.Text = "5";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// button6
//
this.button6.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button6.Location = new System.Drawing.Point(148, 155);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(46, 37);
this.button6.TabIndex = 6;
this.button6.Text = "6";
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// button7
//
this.button7.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button7.Location = new System.Drawing.Point(12, 99);
this.button7.Name = "button7";
this.button7.Size = new System.Drawing.Size(46, 37);
this.button7.TabIndex = 7;
this.button7.Text = "7";
this.button7.UseVisualStyleBackColor = true;
this.button7.Click += new System.EventHandler(this.button7_Click);
//
// button8
//
this.button8.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button8.Location = new System.Drawing.Point(81, 99);
this.button8.Name = "button8";
this.button8.Size = new System.Drawing.Size(46, 37);
this.button8.TabIndex = 8;
this.button8.Text = "8";
this.button8.UseVisualStyleBackColor = true;
this.button8.Click += new System.EventHandler(this.button8_Click);
//
// button9
//
this.button9.AllowDrop = true;
this.button9.Font = new System.Drawing.Font("Modern No. 20", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button9.Location = new System.Drawing.Point(148, 99);
this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(46, 37);
this.button9.TabIndex = 9;
this.button9.Text = "9";
this.button9.UseVisualStyleBackColor = true;
this.button9.Click += new System.EventHandler(this.button9_Click);
//
// button10
//
this.button10.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button10.Location = new System.Drawing.Point(219, 262);
this.button10.Name = "button10";
this.button10.Size = new System.Drawing.Size(46, 37);
this.button10.TabIndex = 10;
this.button10.Text = "+";
this.button10.UseVisualStyleBackColor = true;
this.button10.Click += new System.EventHandler(this.addbtn_Click);
//
// button11
//
this.button11.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button11.Location = new System.Drawing.Point(12, 262);
this.button11.Name = "button11";
this.button11.Size = new System.Drawing.Size(46, 37);
this.button11.TabIndex = 11;
this.button11.Text = "0";
this.button11.UseVisualStyleBackColor = true;
this.button11.Click += new System.EventHandler(this.button11_Click);
//
// button12
//
this.button12.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button12.Location = new System.Drawing.Point(219, 53);
this.button12.Name = "button12";
this.button12.Size = new System.Drawing.Size(50, 37);
this.button12.TabIndex = 12;
this.button12.Text = "CLEAR";
this.button12.UseVisualStyleBackColor = true;
this.button12.Click += new System.EventHandler(this.button12_Click);
//
// button13
//
this.button13.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button13.Location = new System.Drawing.Point(219, 208);
this.button13.Name = "button13";
this.button13.Size = new System.Drawing.Size(46, 37);
this.button13.TabIndex = 13;
this.button13.Text = "-";
this.button13.UseVisualStyleBackColor = true;
this.button13.Click += new System.EventHandler(this.subbtn_Click);
//
// button14
//
this.button14.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button14.Location = new System.Drawing.Point(215, 154);
this.button14.Name = "button14";
this.button14.Size = new System.Drawing.Size(50, 37);
this.button14.TabIndex = 14;
this.button14.Text = "*";
this.button14.UseVisualStyleBackColor = true;
this.button14.Click += new System.EventHandler(this.mulbtn_Click);
//
// button15
//
this.button15.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button15.Location = new System.Drawing.Point(219, 105);
this.button15.Name = "button15";
this.button15.Size = new System.Drawing.Size(46, 37);
this.button15.TabIndex = 15;
this.button15.Text = "/";
this.button15.UseVisualStyleBackColor = true;
this.button15.Click += new System.EventHandler(this.divbtn_Click);
//
// button16
//
this.button16.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button16.Location = new System.Drawing.Point(148, 262);
this.button16.Name = "button16";
this.button16.Size = new System.Drawing.Size(50, 37);
this.button16.TabIndex = 16;
this.button16.Text = "=";
this.button16.UseVisualStyleBackColor = true;
this.button16.Click += new System.EventHandler(this.equal_Click);
//
// button18
//
this.button18.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button18.Location = new System.Drawing.Point(12, 53);
this.button18.Name = "button18";
this.button18.Size = new System.Drawing.Size(212, 37);
this.button18.TabIndex = 18;
this.button18.UseVisualStyleBackColor = true;
//
// button17
//
this.button17.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button17.Location = new System.Drawing.Point(81, 262);
this.button17.Name = "button17";
this.button17.Size = new System.Drawing.Size(46, 37);
this.button17.TabIndex = 19;
this.button17.Text = ".";
this.button17.UseVisualStyleBackColor = true;
this.button17.Click += new System.EventHandler(this.button17_Click);
//
// HKABIRCALCULATOR
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Fuchsia;
this.ClientSize = new System.Drawing.Size(290, 324);
this.Controls.Add(this.button17);
this.Controls.Add(this.button18);
this.Controls.Add(this.button16);
this.Controls.Add(this.button15);
this.Controls.Add(this.button14);
this.Controls.Add(this.button13);
this.Controls.Add(this.button12);
this.Controls.Add(this.button11);
this.Controls.Add(this.button10);
this.Controls.Add(this.button9);
this.Controls.Add(this.button8);
this.Controls.Add(this.button7);
this.Controls.Add(this.button6);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "HKABIRCALCULATOR";
this.Text = "HKABIRCALCULATOR";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Button button8;
private System.Windows.Forms.Button button9;
private System.Windows.Forms.Button button10;
private System.Windows.Forms.Button button11;
private System.Windows.Forms.Button button12;
private System.Windows.Forms.Button button13;
private System.Windows.Forms.Button button14;
private System.Windows.Forms.Button button15;
private System.Windows.Forms.Button button16;
private System.Windows.Forms.Button button18;
private System.Windows.Forms.Button button17;

}
}

Everyone are come here for the following terms:

How to make a C sharp calculator,C sharp calculator,c# calculator, free code of c-sharp calculator,source code of  C sharp calculator,code of c sharp calculator

 

Related Post or you may like:

 

knowledgediarybd.com © 2017
shares