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

  • Home
  • SEARCH
  • 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 4082796
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:13:54+00:00 2026-05-20T18:13:54+00:00

Possible Duplicate: How to handle when the backspace button is pressed and the input

  • 0

Possible Duplicate:
How to handle when the backspace button is pressed and the input panel has digit grouped numbers. E.g. 434,343,334.232.

Basically the question says it all, I’m making a calculator in c# and I’m stuck on this problem. When digit grouping is hit the numbers get separated by commas, when the user hits the backspace button, the commas act like characters that get deleted.

inputPanelTextBox.Text = inputPanelTextBox.Text.Replace(“,”, “”) I put this piece of code under my backspace click event. The problem is that say the panel has 234,232 and the user presses the backspace button, the comma is gone as well as the 2 on the far right.

What I want to happen is the same way the windows 7 calculator does when the digit grouped menu is checked and the user hits the backspace.

Any idea of how to go about this? Thank you so much in advance.

  • 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-05-20T18:13:55+00:00Added an answer on May 20, 2026 at 6:13 pm

    How about you store the number just as a number then format the number to look nice when you output it. The same thing will work with string.Format(). You could reformat the number into the display string every time the user hits backspace or adds a new digit. There are lots of the string format modifiers listed here.

    int numWithComma = 3000;
    int numWithoutComma = 50;
    Console.WriteLine("numWithComma: {0:n}", numWithComma);
    Console.WriteLine("numWithoutComma: {0:n}", numWithoutComma);
    
    // prints:
    // numWithComma: 3,000.00
    // numWithoutComma: 50.00
    

    If I were making this calculator, I would save the number in a double, then when the number needs to be displayed I would run it through a function like this and display the string to the user:

    private static string FormatForDisplay(double number)
    {
        return string.Format("{0:n}", number);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How can I properly handle 404 in ASP.NET MVC? I've made the
Possible Duplicate: How to handle diacritics (accents) when rewriting 'pretty URLs' I want to
Possible Duplicate: Why can't Python handle true/false values as I expect? False = True
Possible Duplicate: How does .net managed memory handle value types inside objects? I have
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
Possible Duplicate: .NET - What’s the best way to implement a catch all exceptions
Possible Duplicate: What Ruby IDE do you prefer? I've generally been doing stuff on
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have

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.