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 4234366
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:20:41+00:00 2026-05-21T02:20:41+00:00

So I’m working on a calculator application in C-Sharp and I want to prevent

  • 0

So I’m working on a calculator application in C-Sharp and I want to prevent people from entering more than 1 period/point at once. So they can’t type “…..” or “1..1” or “1.1.1”
Really just stuff like that…. I would also like to prevent them from adding alphabetical characters in by typing them in with the keyboard, characters like “a, b, c”.

I was told to use a MaskedTextBox, and I want to know if that is correct. Also, if it is correct, how would I implement it into my code? I’m a complete beginner when it comes to C#, so I would like some help (toned down for a beginner).

So far the code I have written is:

    double total1 = 0;
    double total2 = 0;

    public Form1()
    {
        InitializeComponent();
    }

    private void btnOne_Click(object sender, EventArgs e)
    {
        txtDisplay.Text = txtDisplay.Text + btnOne.Text;
    }

    private void btnTwo_Click(object sender, EventArgs e)
    {
        txtDisplay.Text = txtDisplay.Text + btnTwo.Text;
    }

    private void btnThree_Click(object sender, EventArgs e)
    {
        txtDisplay.Text = txtDisplay.Text + btnThree.Text;
    }

    private void btnFour_Click(object sender, EventArgs e)
    {
        txtDisplay.Text = txtDisplay.Text + btnFour.Text;
    }

    private void btnFive_Click(object sender, EventArgs e)
    {
        txtDisplay.Text = txtDisplay.Text + btnFive.Text;
    }

    private void btnSix_Click(object sender, EventArgs e)
    {
        txtDisplay.Text = txtDisplay.Text + btnSix.Text;
    }

    private void btnSeven_Click(object sender, EventArgs e)
    {
        txtDisplay.Text = txtDisplay.Text + btnSeven.Text;
    }

    private void btnEight_Click(object sender, EventArgs e)
    {
        txtDisplay.Text = txtDisplay.Text + btnEight.Text;
    }

    private void btnNine_Click(object sender, EventArgs e)
    {
        txtDisplay.Text = txtDisplay.Text + btnNine.Text;
    }

    private void btnZero_Click(object sender, EventArgs e)
    {
        txtDisplay.Text = txtDisplay.Text + btnZero.Text;
    }

    private void btnClear_Click(object sender, EventArgs e)
    {
        txtDisplay.Clear();
    }

    private void btnPlus_Click(object sender, EventArgs e)
    {
        total1 = total1 + double.Parse(txtDisplay.Text);
        txtDisplay.Clear();
    }

    private void btnEquals_Click(object sender, EventArgs e)
    {
        total2 = total1 + double.Parse(txtDisplay.Text);
        txtDisplay.Text = total2.ToString();
        total1 = 0;

    }

    private void btnPoint_Click(object sender, EventArgs e)
    {
        txtDisplay.Text = txtDisplay.Text + btnPoint.Text;
    }

    private void label1_Click(object sender, EventArgs e)
    {

    }

    private void txtDisplay_TextChanged(object sender, EventArgs e)
    {

    }
}

So I ask… how/where do I add in this “MaskedTextBox” – if that is correct? How do I implement it? What makes it work?

Thanks!

  • 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-21T02:20:42+00:00Added an answer on May 21, 2026 at 2:20 am

    You don’t need a MaskedTextBox, since you’re simulating the keypad with your buttons. Just put something like this in btnPoint_Click:

    private void btnPoint_Click(object sender, EventArgs e)     
    {         
        if (!txtDisplay.Text.Contains("."))
        {
            txtDisplay.Text = txtDisplay.Text + btnPoint.Text;    
        } 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
i want to parse a xhtml file and display in UITableView. what is the

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.