Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8161547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:31:20+00:00 2026-06-06T18:31:20+00:00

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

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

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

        bool plus;
        bool minus;
        bool multiply;
        bool divide;

        private void button0_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "0";
        }

        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 buttonPlus_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
                return;
            else
            {
                plus = true;
                textBox1.Text = textBox1.Text + " + ";
            }
        }

        private void buttonDivide_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
                return;
            else
            {
                divide = true;
                textBox1.Text = textBox1.Text + " / ";
            }
        }

        private void buttonMinus_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
                return;
            else
            {
                minus = true;
                textBox1.Text = textBox1.Text + " - ";
            }
        }

        private void buttonMultiply_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
                return;
            else
            {
                multiply = true;
                textBox1.Text = textBox1.Text + " * ";
            }
        }

        private void buttonClear_Click(object sender, EventArgs e)
        {
            textBox1.Text = string.Empty;
        }

        private void buttonEquals_Click(object sender, EventArgs e)
        {
            if (plus)
            {

            }

            if (minus)
            {

            }

            if (multiply)
            {

            }

            if (divide)
            {

            }
        }


    }
}

The part I am stuck on, is after I press a math button (+,-,/,*). I only want one character to show in the textbox, unless I press another number.

Example: Right now, this is what happens:
87 + + + + + + + +

I want 87 +
and I want it where I can add another if the user adds another number, so like 87 + 87 + etc.

Also, I need a little direction when it comes to adding the math logic.

I was thinking of somehow storing whatever was in the string prior to a math sign in a variable, then doing the same for the numbers proceeding the math sign. Is that fine or is there an easier/less complicated way to accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:31:22+00:00Added an answer on June 6, 2026 at 6:31 pm

    For the +-*\ situation.. I would suggest a Boolean property like lastCharIsSymbol. Whenever you click a number set it equal to false, and when you click a symbol set it equal to true. Then you can add an if statement in your symbol click events to only add the symbol IF lastCharIsSymbol = false.

    public Boolean lastCharIsSymbol {get;set;}
    
    private void button9_Click(object sender, EventArgs e)
    {
        textBox1.Text = textBox1.Text + "9";
        lastCharIsSymbol = false;
    }
    
    private void buttonPlus_Click(object sender, EventArgs e)
    {
        if (textBox1.Text == "" || lastCharIsSymbol)
            return;
        else
        {
            plus = true;
            textBox1.Text = textBox1.Text + " + ";
            lastCharIsSymbol = true;
        }
    }
    

    If you would rather not do this, you can also change up your if statement to just take a substring of whatever is in the textbox and find out what the last character is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using System.ComponentModel; using System.Data;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Net;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.