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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:07:01+00:00 2026-05-28T05:07:01+00:00

I am messing around with C# and am making a prototype GUI (with no

  • 0

I am messing around with C# and am making a prototype GUI (with no game attached, just messing around with buttons and button colors). I’m running into an error:

private void temperValue_Load(object sender, EventArgs e)
    {
        int temperInt = 23;
        temperInt = Convert.ToInt32(temperValue.Text);

        if (temperInt >= 70)
        {
            temperButton.BackColor = System.Drawing.Color.Red;
        }
        else if (temperInt >= 40 & <= 69)
        {
            temperButton.BackColor = System.Drawing.Color.DarkOrange;
        }
    }

On the “else if” line, I have an error from both the “<=” and the “69)”. The “<=” error is “Invalid expression term ‘<='”, and the four errors for the “69)” is “) expected”, “Invalid expression term ‘)'”, and two “; expected” errors.

There are no variables outside of this snippet of code that are affecting this code. Every variable called is defined inside the snippet.

(For anyone curious, “temper” stands for “Temperature”)

  • 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-28T05:07:02+00:00Added an answer on May 28, 2026 at 5:07 am

    You cannot take shortcuts in your boolean conditions like that.

    else if (temperInt >= 40 & <= 69)
    

    Must instead be written as:

    else if (temperInt >= 40 && temperInt <= 69)
    

    Note that when making boolean comparisons, you usually want to use the double ampersand &&. This causes short-circuiting (only evaluate both sides if the left side succeeds) which is usually what is wanted. And as I said, you need to include the temperInt identifier both times — you can’t say “where some variable is greater than one value and less than another” like in a SQL BETWEEN clause.

    Update: Fixed answer per Eric’s suggestion.

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

Sidebar

Related Questions

After messing around a little with making a GUI with the Windows API, I
Im just messing around with Ruby on Rails and HTML. This question isn't about
I was messing around with making a command line parser and was wondering what
I am messing around with a basic CAAnimation example where Im just trying to
I was just messing around with XNA and trying to get a simple player
Messing around with 'extension functions' for the List module. (I spent quite a while
I am messing around with a toy interpreter in Java and I was considering
I was messing around with RhinoMocks this morning and couldn't run my tests because
I am messing around with Doctrine (version 1.0.3) to see if would make a
I'm messing around with some C code using floats, and I'm getting 1.#INF00, -1.#IND00

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.