wrong operation with my calculator
Posted by Kutekriss
Last Updated: November 04, 2013
All calculations giving answer "0". 
please help fix this



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

namespace ECUT_EXO5
{
    public partial class Calculator : Form
    {
        string   Number1;
        string operation;
        decimal Results;
        bool check;
        public Calculator()
        {
            InitializeComponent();
        }

        private void button17_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Button btnNumbers = (Button)sender;
            if (check == true)
            {
                txtDisplay.Text = " ";
            }
            txtDisplay.Text += btnNumbers.Text;
            check = false;
            
        }

        private void button2_Click(object sender, EventArgs e)
        {

        }

        private void button11_Click(object sender, EventArgs e)
        {
            if (txtDisplay.Text.Contains("."))
            {
                return;
            }
            txtDisplay.Text += button11.Text;
        }

        private void button18_Click(object sender, EventArgs e)
        {
            Button btnOperations = (Button)sender;
            operation = txtDisplay.Text;
            Number1 =txtDisplay.Text;
            check = true;
        }

        private void button16_Click(object sender, EventArgs e)
        {
            if (operation == ("+"))
            {
                Results = Convert.ToDecimal(Number1) +
                    Convert.ToDecimal(txtDisplay.Text);
                txtDisplay.Text = Convert.ToString(Results);
            }
            else if (operation == ("-"))
            {
                Results = Convert.ToDecimal(Number1) - Convert.ToDecimal(txtDisplay.Text);
                txtDisplay.Text = Convert.ToString(Results);
            }
            else if (operation == ("*"))
            {
                Results = Convert.ToDecimal(Number1) * Convert.ToDecimal(txtDisplay.Text);
                txtDisplay.Text = Convert.ToString(Results);
            }
            else if (operation == ("/"))
            {
                Results = Convert.ToDecimal(Number1) / Convert.ToDecimal(txtDisplay.Text);
                txtDisplay.Text = Convert.ToString(Results);
            }
        }

        private void button10_Click(object sender, EventArgs e)
        {
            txtDisplay .Text = " ";
        }

    }
}

Related Content
Simple Calculator using C#
Simple Calculator using C#
Samath | Dec 30, 2020
Calculator Program in Java
Calculator Program in Java
Samath | Jan 07, 2021
Simple C++ Calculator
Simple C++ Calculator
Samath | Jan 05, 2017
Simple Calculator using Python
Simple Calculator using Python
Samath | Jan 09, 2017
GPA Calculator using C#
GPA Calculator using C#
Samath | Jan 01, 2021
Simple GPA calculator in Java
Simple GPA calculator in Java
Samath | Jan 17, 2024
GPA Calculator in C++
GPA Calculator in C++
Samath | Jan 17, 2024
GPA Calculator using Python
GPA Calculator using Python
Samath | Jan 20, 2024
Scientific Calculator using C#
Scientific Calculator using C#
Samath | Jan 08, 2021