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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:25:42+00:00 2026-05-24T00:25:42+00:00

I have a string that looks like this: TEXT MORETEXT 227.905 174.994 180 1111

  • 0

I have a string that looks like this:

TEXT  MORETEXT  227.905  174.994  180  1111

I am curious on how I can change the decimal to only have 2 places.

So instead of the string above, I would like it to be:

TEXT  MORETEXT  227.90  174.99  180  1111 #rounding down

OR

TEXT  MORETEXT  227.91  174.99  180  1111 #rounding up

Does anyone know how to grab this string and change the values to a decimal and then trim the decimal down?


EDIT:

So if I had a file that reads: (Note: The file has multiple lines)

TEXT  MORETEXT  227.905  174.994  180  1111
TEXT  MORETEXT  227.905  174.994  180  1111
TEXT  MORETEXT  227.905  174.994  180  1111

and I want it to go into a RichTextBox like this:

TEXT  MORETEXT  227.90  174.99  180  1111
TEXT  MORETEXT  227.90  174.99  180  1111
TEXT  MORETEXT  227.90  174.99  180  1111

How could I do that?


EDIT2:

        string[] listOneLines = null;
        string[] listTwoLines = null;
        string[] listUserLines = null;

        // Splits the lines in the rich text boxes
        listOneLines = removePKG1EndingsRichTextBox.Text.Split('\n');
        listTwoLines = removePKG2EndingsRichTextBox.Text.Split('\n');
        listUserLines = removeUserEndingsRichTextBox.Text.Split('\n');

        string[] myLines = removePKG1EndingsRichTextBox.Text.Split('\n');
        StringBuilder sb = new StringBuilder();
        foreach(string myLine in myLines)
        {
            string[] piecesStringArray = removePKG1EndingsRichTextBox.Text.Split(' ');  //Assuming those are tabs
            double d1 = Convert.ToDouble(piecesStringArray[2]);
            double d2 = Convert.ToDouble(piecesStringArray[3]);
            double round1 = Math.Round(d1, 2);
            double round2 = Math.Round(d2, 2);

            sb.AppendLine(piecesStringArray[0] + piecesStringArray[1] + round1 + round2 + piecesStringArray[4] + piecesStringArray[5]);
        }
        listOneLines = sb.ToString(); #does not work..

        // Set the selection mode to multiple and extended.
        placementOneListBox.SelectionMode = SelectionMode.MultiExtended;
        placementTwoListBox.SelectionMode = SelectionMode.MultiExtended;
        userDefinedListBox.SelectionMode = SelectionMode.MultiExtended;

        // Shutdown the painting of the ListBox as items are added.
        placementOneListBox.BeginUpdate();
        placementTwoListBox.BeginUpdate();
        userDefinedListBox.BeginUpdate();

        // Display the items in the listbox.
        foreach (var item in listOneLines)
            placementOneListBox.Items.Add(item);
        foreach (var item2 in listTwoLines)
            placementTwoListBox.Items.Add(item2);
        foreach (var item3 in listUserLines)
            userDefinedListBox.Items.Add(item3);

        // Allow the ListBox to repaint and display the new items.
        placementOneListBox.EndUpdate();
        placementTwoListBox.EndUpdate();
        userDefinedListBox.EndUpdate();

I was trying to reduce the decimal values on each line in the RTB before I upload it to the ListBox. However I am struggling…

  • 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-24T00:25:43+00:00Added an answer on May 24, 2026 at 12:25 am

    You can use:

    string[] piecesStringArray = myLine.Split('\t');  //Assuming those are tabs
    double d1 = Convert.ToDouble(piecesStringArray[2];
    double d2 = Convert.ToDouble(piecesStringArray[3];
    double round1 = Math.Round(d1, 2);
    double round2 = Math.Round(d2, 2);
    //Now recreate your string
    

    Of course you should add error checking and the like. If you want to go against conventional rounding, check out Math.Floor() and Math.Ceil(). You’ll need to scale the number by powers of ten to get it working right.

    To get myLine you can use:

    string[] myLines = entireFileText.Split(Environment.NewLine);
    for(string myLine in myLines)
    {
         //Previous code
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a RichTextBox that looks like this: TEXT NEXT_TEXT 10.505 -174.994 0 TEXT
I have a huge string that looks like this: Text Text Text Text Text
I have a method that looks like this: public static String escape(String text) {
If I have a string that looks like this: $myString = [sometext][moretext][993][112]This is a
I have a problem that looks like this: My string of text looks like
I have a text string that looks like this var1=red&var2=green&var3=blue&var4=magenta How can manipulate this
in vb.net i have a string that looks like this text text text so
I have a String that looks like this String = Förpackning Flaska (375 ml)
I have a string that looks like this: <name>-<gender>-<age>.jpg I want to be very
I have a string that looks like this: 9/1/2009. I want to convert it

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.