Results 1 to 35 of 35

Thread: [vb.net] Sorting decimal in ascending order in richtextbox

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2013
    Posts
    108

    [vb.net] Sorting decimal in ascending order in richtextbox

    I need to sort in ascending numbers the lines of a richtextbox, which got decimals in the follow format:

    0.00001302 - 283000
    0.00001315 - 295800
    0.00001328 - 292600
    0.00001333 - 7700
    0.00001341 - 308500
    I'm trying to sort the lines to obtain an output like:

    0.00001341 - 308500
    0.00001333 - 7700
    0.00001328 - 292600
    0.00001315 - 295800
    0.00001302 - 283000
    Ive tried

    Code:
    RichTextBox1.Lines = RichTextBox1.Lines.OrderBy(Function(x) Decimal.Parse(x)).ToArray
    and


    Code:
    Dim lines() As String = RichTextBox1.Lines
            Dim value = lines.Select(Function(x) Convert.ToInt32(x)).OrderByDescending(Function(x) x)
            RichTextBox1.Text = String.Join(Environment.NewLine, value)
    but for both I get the same error:

    System.FormatException: '"Input string is not in correct format"'
    Clearly the sorting doesn't like the format of the lines, so how can I make it to do not care about the format and just caring about the decimals? Thanks
    Last edited by matty95srk; Feb 14th, 2022 at 07:28 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width