Tweet
SIGN UP
MEMBER LOGIN:
TECHNOLOGIES
.NET 4.5
.NET Remoting in C#
Active Directory C#
ADO.NET in C#
AJAX in C#
Algorithms in C#
Android Programming
Articles C#
ASP, JavaScript, CSS
ASP.NET Controls in C#
ASP.NET MVC with C#
ASP.NET Programming
BizTalk Server
C# Assemblies
C# Language
C# Tutorials
C, C++, MFC
Career Advice
Chapters
Cloud Computing
COBOL.NET
Coding Best Practices
COM Interop
Compact Framework
Cryptography C#
Crystal Reports C#
Current Affairs
Custom Controls C#
Databases & DBA
Deployment
Design & Architecture
DirectX C#
Enterprise Development
Error Zone
Exception Handling C#
Expression Studio
F#
Files, Directories in C#
Financial Applications
Games Programming C#
GDI+ & Graphics
Hardware
How do I
HTML 5
Internet & Web
iPhone/iPad
Java
Java and .NET
JQuery
JSP
Leadership
Learn .NET
LINQ with C#
Metro Style Apps in C#
Mobile & Embedded
MonoDevelop
MSMQ in C#
Multithreading in C#
Networking
Office Development
OOP/OOD
Operating Systems
PHP
Printing in C#
Products
Project Management
Reports using C#
Robotics & Hardware
Security in .NET
SharePoint
Silverlight with C#
Smart Devices
Speech in C#
SQL
SQL Server 2012
String in C#
Team Foundation & VSS
Testing
Visual Basic .NET
Visual C#
Visual Studio .NET
Visual Studio 11
Visual Studio 2010
VS LightSwitch 2011
WCF with C#
Web Forms C#
Web Services in C#
WebForms Controls
Windows 8 in C#
Windows Controls C#
Windows Forms C#
Windows Phone in C#
Windows PowerShell
Windows Services in C#
Workflow Foundation in C#
WPF with C#
XAML with C#
XML in C#
XNA with C#
FORUMS
BLOGS
VIDEOS
INTERVIEWS
CERTIFICATIONS
DOWNLOADS
BOOKS
LINKS
NEWS
Learn .NET in 60 days – Part 1 (13 Labs)
Learn MVC (Model view controller) Step by Step ...
Learn C# Corner - Home
Using Border Radius and Gradients in CSS3: Part I
Learn C# Corner - Footer
Learn .NET and C# in 60 Days Lab13(Day 5): - C ...
iPhone 5 First Look
Samsung Galaxy Note Review
WCF - Authentication and Authorization in Ente ...
How to write a good article on C# Corner
Blog
Calculator in c#
Posted by
vaibhav kanase
in
Blogs
|
C# Language
on
Nov 23, 2011
Here I show you how to create simple calculator in C#.
Tweet
513
0
0
public
partial
class
Form1
:
Form
{
double
a,b;
int
i;
double
ans;
public
Form1()
{
InitializeComponent();
}
private
void
button1_Click(
object
sender,
EventArgs
e)
{
textBox1.Text = textBox1.Text +
"1"
;
}
private
void
button2_Click(
object
sender,
EventArgs
e)
{
textBox1.Text = textBox1.Text +
"2"
;
}
private
void
button3_Click(
object
sender,
EventArgs
e)
{
textBox1.Text = textBox1.Text +
"3"
;
}
private
void
button4_Click(
object
sender,
EventArgs
e)
{
textBox1.Text = textBox1.Text +
"4"
;
}
private
void
button5_Click(
object
sender,
EventArgs
e)
{
textBox1.Text = textBox1.Text +
"5"
;
}
private
void
button6_Click(
object
sender,
EventArgs
e)
{
textBox1.Text = textBox1.Text +
"6"
;
}
private
void
button7_Click(
object
sender,
EventArgs
e)
{
textBox1.Text = textBox1.Text +
"7"
;
}
private
void
button8_Click(
object
sender,
EventArgs
e)
{
textBox1.Text = textBox1.Text +
"8"
;
}
private
void
button9_Click(
object
sender,
EventArgs
e)
{
textBox1.Text = textBox1.Text +
"9"
;
}
private
void
button11_Click(
object
sender,
EventArgs
e)
{
textBox1.Text = textBox1.Text +
"0"
;
}
private
void
button19_Click(
object
sender,
EventArgs
e)
{
textBox1.Text = textBox1.Text +
"."
;
}
private
void
button16_Click(
object
sender,
EventArgs
e)
{
a =
Convert
.ToDouble(textBox1.Text);
textBox1.Text =
""
;
i = 1;
}
private
void
button12_Click(
object
sender,
EventArgs
e)
{
a =
Convert
.ToDouble(textBox1.Text);
textBox1.Text =
""
;
i = 2;
}
private
void
button13_Click(
object
sender,
EventArgs
e)
{
a =
Convert
.ToDouble(textBox1.Text);
textBox1.Text =
""
;
i = 3;
}
private
void
button14_Click(
object
sender,
EventArgs
e)
{
a =
Convert
.ToDouble(textBox1.Text);
textBox1.Text =
""
;
i = 4;
}
private
void
button15_Click(
object
sender,
EventArgs
e)
{
b =
Convert
.ToDouble(textBox1.Text);
switch
(i)
{
case
1:
ans = a + b;
textBox1.Text = (
""
+ans);
break
;
case
2:
ans = a - b;
textBox1.Text = (
""
+ ans);
break
;
case
3:
ans = a * b;
textBox1.Text = (
""
+ ans);
break
;
case
4:
ans = a / b;
textBox1.Text = (
""
+ ans);
break
;
default
:
MessageBox
.Show(
"Error"
);
break
;
}
}
private
void
button10_Click(
object
sender,
EventArgs
e)
{
textBox1.Text =
""
;
}
private
void
button20_Click(
object
sender,
EventArgs
e)
{
this
.Close();
}
private
void
Form1_Load(
object
sender,
EventArgs
e)
{
}
}
Output
share this blog :
Usage of Extensions method in C#..
Leverage “using” in C#
Related Blogs
How to make simple Calculator in c#
C# calculator
post comment
Sponsored by
Become a Sponsor
More Blogs from this Blogger
Calculator in c#
Form view in ASP.NET
View All
Latest Blogs
WebPart Collector or WebPart Finder
Free Ride is Over for Desktop Developers in Visual Studio 11
DotNet developers most used application/tools launching through 'Run'
80-inch Windows 8 Tablet
Data encapsulation
Option to access the Column Names in Data table
Open multiple windows in browser startup. (Multiple homepages option)
I'm Sorry
const and readonly
Address, Binding and Contract in WCF
View All
Sponsored by
Become a Sponsor