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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:43:29+00:00 2026-05-27T01:43:29+00:00

I’m currently working on a homework assignment where I need to set up a

  • 0

I’m currently working on a homework assignment where I need to set up a calculator-type program. It needs to read one or two user-input values (depending on the calculation), and then perform the calculation based on the values.

I currently have

  • 2 textBoxes (tbInput1 and tbInput2),
  • 4 radioButtons,
  • one button (btnCalc)
  • a blank label in which the result will be displayed.

Two of the radioButtons (rbtnTrap and rbtnFak) disable the first textBox when checked; the other two need two values to be entered, and for that reason enable both textBoxes when checked. btnCalc is supposed to enable itself when the relevant number of textBoxes have value – the relevant number of textBoxes depends on which radio button is checked.

The problem is that when I check rbtnTrap or rbtnFak (disabling tbInput1) and enter an integer in tbInput2, btnCalc stays disabled.

I’ll try to explain what I have so far:

  • In the _TextChanged event for tbInput1, I have an exact copy of the second if block posted below. tbInput1 is only active when rbtnPot OR rbtnFib are checked, so that control only runs when that is the case.
  • In the _TextChanged event for tbInput2, I have the below, since tbInput2 is always enabled, and the control must run no matter which radio button is checked, although the control should run differently if i check rbtnTrap OR rbtnFak as opposed to rbtnPot OR rbtnFib.

Or that’s my understanding of it. I’m certainly open to suggestions and corrections.

private void tbInput2_TextChanged(object sender, EventArgs e)
{
    //For single-field values
    if ((rbtnTrap.Checked || rbtnFak.Checked) && 
        !string.IsNullOrWhiteSpace(this.tbInput2.Text))
    {
        btnCalc.Enabled = true;
    }
    else
    {
        btnCalc.Enabled = false;
    }
    // For multi-field values
    if ((rbtnPot.Checked || rbtnFib.Checked) && 
        (!string.IsNullOrWhiteSpace(this.tbInput1.Text)
        && !string.IsNullOrWhiteSpace(this.tbInput2.Text)))
    {
        btnCalc.Enabled = true;
    }
    else
    {
        btnCalc.Enabled = false;
    }
}
  • 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-27T01:43:30+00:00Added an answer on May 27, 2026 at 1:43 am

    Because it is a homework, I am not going to give your the straight answer, but instead a hint: the problem is in the code of the tbInput2_TextChanged event (code that you posted).

    When rbtnTrap or rbtnFak are checked, your code will be run following such a path you don’t think it will. Set a breakpoint (F9) on the first line of the tbInput2_TextChanged code and run the code step by step (F10) after entering some text in tbInput2.
    You will see why your button btnCalc is enabled as you think it is, but disabled in the next moment.

    Feel free to comment if you need more help afterwards. 🙂


    EDIT

    The problem comes from your if blocks. When one of rbtnTrap and rbtnFak is checked:

    • your code will run in the if clause of the first block and then do btnCalc.Enabled = true; but…
    • it will also run in the else clause of the second block (because (rbtnPot.Checked || rbtnFib.Checked) is false) and thus do btnCalc.Enabled = false;.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.