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.

Recommended Answers

All 2 Replies

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

commented: N.A +13

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.