How to remove vb.net Richtextbox lines that not contains specific text?
Date : March 29 2020, 07:55 AM
Hope this helps This code will remove any line from a richtextbox RichTextbox1 that does not contain "Test" on it. Remember to add Imports System.Text.RegularExpressions to the top of your code. Private Sub RemoveLines()
Dim lines As New List(Of String)
lines = RichTextBox1.Lines.ToList
Dim FilterText = "Test"
For i As Integer = lines.Count - 1 To 0 Step -1
If Not Regex.IsMatch(lines(i), FilterText) Then
lines.RemoveAt(i)
End If
Next
RichTextBox1.Lines = lines.ToArray
End Sub
|
How to remove empty lines while preserving the formatting of the richtextbox in c#
Date : March 29 2020, 07:55 AM
wish of those help The Golden Rule about RichTextBoxes is to never change the Text directly, once it has any formatting. To add you use AppendText and to change you need to use the Select, Cut, Copy & Paste.. methods to preserve the formatting! string needle = "\r\r"; // only one possible cause of empty lines
int p1 = richTextBox1.Find(needle);
while (p1 >= 0)
{
richTextBox1.SelectionStart = p1;
richTextBox1.Select(p1, needle.Length);
richTextBox1.Cut();
p1 = richTextBox1.Find(needle);
}
|
Sanitize input in richtextbox to remove blank lines
Date : March 29 2020, 07:55 AM
will help you I am trying to sanitize input in a richtextbox to remove blank lines. , Modify this line: $richtextbox1.Text = $richtextbox1.Text -replace ";", "`n" -replace ",", "`n" -replace " ", ""
$richtextbox1.Text = $richtextbox1.Text -replace ";", "`n" -replace ",", "`n" -replace " ", "" -replace '(?s)(\n){2,}', "`n" -replace '\n$',''
|
remove speical string from lines richtextbox vb.net
Tag : vb.net , By : enginecrew
Date : March 29 2020, 07:55 AM
this one helps. you are lucky, i've been working since morning for similar code to what you want, here we go I made some changes on my code to fit ur request Dim x As String = ""
Dim y As String = ""
For Each strLine As String In TextBox1.Text.Split(vbNewLine) 'TO read each line in text box
Dim ii As Integer = strLine.Length
Dim i As Integer = 0
For i = 0 To ii - 1
y = strLine.Substring(i, 1)
If y = "=" Then
x = strLine.Substring(0, i)
TextBox2.AppendText(x & Environment.NewLine)
End If
Next
Next
|
Remove Duplicate Lines from textbox or richtextbox vb.net
Date : March 29 2020, 07:55 AM
Does that help It looks to me like you want to remove repeating lines, and not simply get a list of distinct values (as demonstrated by the presence of the 'b' before the 'd' in the desired output). If so, you can use code like this: Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim lines As New List(Of String)(TextBox1.Lines)
For i As Integer = lines.Count - 1 To 1 Step -1
If lines(i) = lines(i - 1) Then
lines.RemoveAt(i)
End If
Next
TextBox1.Lines = lines.ToArray
End Sub
|