Results 1 to 3 of 3

Thread: Remove empty RichTextBox lines using LINQ

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2014
    Posts
    30

    Remove empty RichTextBox lines using LINQ

    Hi everyone, I can't think of how to do this using a LINQ query. Without, I've done this:

    Code:
    RichTextBox1.Lines = RichTextBox1.Text.Split(New Char() {ControlChars.Lf}, StringSplitOptions.RemoveEmptyEntries)
    But I'm curious on what you would do using LINQ. Thanks!

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Remove empty RichTextBox lines using LINQ

    something like?...
    Code:
    RTB.Lines = (From line In RTB.Lines Select line Where line <> "").ToArray
    Last edited by Edgemeal; Jan 20th, 2015 at 06:24 PM.

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,538

    Re: Remove empty RichTextBox lines using LINQ

    Quote Originally Posted by Edgemeal View Post
    something like?...
    Code:
    RTB.Lines = (From line In RTB.Lines Select line Where line <> "").ToArray
    That's what I was thinking as well.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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