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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:37:06+00:00 2026-06-14T21:37:06+00:00

Sorry my title is a bit vague, but what I’m trying to do will

  • 0

Sorry my title is a bit vague, but what I’m trying to do will probably take a paragraph to explain.

At the moment what I’m trying to do is this:

  • Gather user in put a from a text box
  • Divide the value entered by 2
  • Display this new value on a label

So, to get user values I’ve done this:

  private void userLengthTextBox_TextChanged(object sender, EventArgs e)
    {
        _userLength = userLengthTextBox.Text;
    }

This is coming in as a string. Then in a new function, I’m converting this string to a single (need it to be a float), calculating half the value entered and then storing it in a new float.

Like so:

    _oldTlX = Convert.ToSingle(_userLength);
    _tlX = _oldTlX / 2;

Then, when I press a button, I’m trying to get this value to display in a label:

 _valueLabel.Text = Convert.ToString(_tlX);

However, when I press the button, the value remains at 0. No matter what I put. As far as I can see I’ve converted the value I need to the correct format needed, but it is still saying I’m doing it wrong.

  • 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-14T21:37:08+00:00Added an answer on June 14, 2026 at 9:37 pm

    I recommend you to use double internally, and then use a format string to show the result in a propper way:

    double _oldTlX;
    if (!double.TryParse(_userLength, out _oldTlX)) return;
    double _tlX = _oldTlX / 2;
    
    _valueLabel.Text = string.Format("{0:f3}", _tlX); // 3 decimal positions
    

    You can also check at the MSDN how to format numeric results.

    Hope it helps.

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

Sidebar

Related Questions

I'm sorry if the title is a bit confusing, but this is my problem:
Sorry if the title isn't clear enough, but in Javascript you can do this
Sorry, the title is a bit hard to understand but I'm not 100% sure
I'm sorry if this is a stupid question or my title is a bit
I'm sorry for the generic title of this question but I wish I was
Sorry for a simple question but i am a bit confused trying to follow
Ok, so that title probably doesn't explain my question well. Hopefully this makes sense.
Hi guys sorry for the awkward title but I think it is a bit
I m really sorry for unclear question title but I am a bit confused
Sorry if the title sounds a bit vague. Stackoverflow posting newbie here. I 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.