Alex
Alex

Reputation: 183

How to make program remove lines in multiline textbox text - Visual Basic?

I want to make a program that'll remove text lines if the line contains "0,00". I seperated the lines with "vbCrLf" in the print function.

This is the function I came up with, can someone correct it?

Public Sub IzVrstic1()
    Dim arrLines() As String = TextOut.Text.Split(CChar(vbLf))
    TextOut.Clear()
    For Each ln As String In arrLines           
        If Not ln.Contains("0,00") Then
            TextOut.Text &= ln & vbCrLf
        End If
    Next

End Sub

Upvotes: 0

Views: 2298

Answers (1)

Ry-
Ry-

Reputation: 224913

Just use the Lines array and Array.FindAll:

TextOut.Lines = Array.FindAll(TextOut.Lines, Function(line) Not line.Contains("0,00"))

Upvotes: 1

Related Questions