In this tutorials will teach how to make a calculator using wpf C# application step by step. How to create the calculator in wpf application in best coding practice.
string CalTotal; int num1; int num2; string option; int result;
private void Button1_Click(object sender, RoutedEventArgs e)
{
txtTotal.Text = txtTotal.Text + "1";
}
private void Button2_Click(object sender, RoutedEventArgs e)
{
txtTotal.Text = txtTotal.Text + "2";
}
private void Button3_Click(object sender, RoutedEventArgs e)
{
txtTotal.Text = txtTotal.Text + "3";
}
private void Button4_Click(object sender, RoutedEventArgs e)
{
txtTotal.Text = txtTotal.Text + "4";
}
private void Button5_Click(object sender, RoutedEventArgs e)
{
txtTotal.Text = txtTotal.Text + "5";
}
private void Button6_Click(object sender, RoutedEventArgs e)
{
txtTotal.Text = txtTotal.Text + "6";
}
private void Button7_Click(object sender, RoutedEventArgs e)
{
txtTotal.Text = txtTotal.Text + "7";
}
private void Button8_Click(object sender, RoutedEventArgs e)
{
txtTotal.Text = txtTotal.Text + "8";
}
private void Button9_Click(object sender, RoutedEventArgs e)
{
txtTotal.Text = txtTotal.Text + "9";
}
private void Button0_Click(object sender, RoutedEventArgs e)
{
txtTotal.Text = txtTotal.Text + "0";
}
private void ButtonPlus_Click(object sender, RoutedEventArgs e)
{
option = "+";
num1 = int.Parse(txtTotal.Text);
txtTotal.Clear();
}
private void ButtonMinus_Click(object sender, RoutedEventArgs e)
{
option = "-";
num1 = int.Parse(txtTotal.Text);
txtTotal.Clear();
}
private void ButtonSub_Click(object sender, RoutedEventArgs e)
{
option = "*";
num1 = int.Parse(txtTotal.Text);
txtTotal.Clear();
}
private void ButtonDiv_Click(object sender, RoutedEventArgs e)
{
option = "/";
num1 = int.Parse(txtTotal.Text);
txtTotal.Clear();
}
private void ButtonClear_Click(object sender, RoutedEventArgs e)
{
txtTotal.Clear();
result = (0);
num1 = (0);
num2 = (0);
}
private void ButtonEql_Click(object sender, RoutedEventArgs e)
{
num2 = int.Parse(txtTotal.Text);
if (option.Equals("+"))
result = num1 + num2;
if (option.Equals("-"))
result = num1 - num2;
if (option.Equals("*"))
result = num1 * num2;
if (option.Equals("/"))
result = num1 / num2;
txtTotal.Text = result + "";
}
What Is the Tesla Pi Phone? Imagine if Tesla, the company that makes famous…
Inventory Management POS systems are now an essential part of modern businesses such as bookshops,…
If you're just beginning to learn Java GUI programming creating an Water System Calculator is a fantastic project for…
GitHub is a powerful tool used by teams and developers around the globe. This guide is…
It's like having a super-smart buddy that is always there to help you write stories,…
The UK is known for its rich history, diverse culture, and most of all its…