0

what is the code for searching for and removing a blank line in a multi-line text box? im using VB Express '08 and can not figure it out.

my problem is im loading a sample.text file and using txtFile.AppendText(ControlChars.NewLine & activetext & ",") to add new text from user input and get a blank line that causes problems when converting the text into my array. it looks like this:
info,info
info,info
info,info
info,info
info,info
info,info

info,info
info,info
please HELP! i am out of ideas and everything else is working except this. all i need is that blank line to go away. lol

any ideas or suggestions would be most appreciated.
can post more of my code if needed.

3
Contributors
2
Replies
17
Views
7 Years
Discussion Span
Last Post by samir_ibrahim
1

to remove the blank lines on reading it ou could do:

Dim tmp() As String = My.Computer.FileSystem.ReadAllText("C:\test.txt").Split(vbNewLine)
        For Each newStr As String In tmp
            If newStr.Length > 2 Then TextBox1.AppendText(newStr & vbNewLine)
        Next

if you want to update the textbox you could do:

Dim tmp() As String = TextBox1.Text.Split(CChar(vbNewLine))
        TextBox1.Clear()
        For Each line As String In tmp
            If line.Length > 1 Then
                TextBox1.AppendText(line & vbNewLine)
            End If
        Next

i've posted both possibility coz it wasnt really clear to me what exactlly u wanted (at what time) ... guess need more coffee

Votes + Comments
N.A
0

You can try this (not tested deeply)

Dim SearchIn = Me.TextBox1.Text
Dim sb As StringBuilder = New StringBuilder(SearchIn)
Me.TextBox1.Text = sb.Replace(vbCrLf + vbCrLf, vbCrLf).ToString
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.