m_s_ifland
New member
- Joined
- Jan 28, 2010
- Messages
- 4
- Programming Experience
- Beginner
Ok, I'm new so go easy on me. I don't know if this is in the right section, so if it's not, sorry.
Goal: To delete extra lines in a text file.
Example:
Current
1 blah blaah blah blaah blah blaah blah blaah blah blaah
2 blah blaah blah blaah blah blaah blah blaah
3 blah blaah blah blaah blah blaah
This is how I want it to look:
1 blah blaah blah blaah blah blaah blah blaah blah blaah
2 blah blaah blah blaah blah blaah blah blaah
3 blah blaah blah blaah blah blaah
Here is the code that I have so far.
This code does this:
1 blah blaah blah blaah blah blaah blah blaah blah blaah 2 blah blaah blah blaah blah blaah blah blaah 3 blah blaah blah blaah blah blaah
Thanks in advance.
Goal: To delete extra lines in a text file.
Example:
Current
1 blah blaah blah blaah blah blaah blah blaah blah blaah
2 blah blaah blah blaah blah blaah blah blaah
3 blah blaah blah blaah blah blaah
This is how I want it to look:
1 blah blaah blah blaah blah blaah blah blaah blah blaah
2 blah blaah blah blaah blah blaah blah blaah
3 blah blaah blah blaah blah blaah
Here is the code that I have so far.
VB.NET:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim lines() As String = {}
Dim sr As New IO.StreamReader("C:\Documents and Settings\Michael S. Ifland\My Documents\Palm Stuff\BibleConverter\lev1.txt")
Dim fileText As String = sr.ReadToEnd()
lines = fileText.Split(vbCrLf)
sr.Close()
Dim sw As New System.IO.FileStream("C:\Documents and Settings\Michael S. Ifland\My Documents\Palm Stuff\BibleConverter\lev11.txt", IO.FileMode.Create)
Dim w As New System.IO.StreamWriter(sw)
Dim i As Integer
For i = 1 To UBound(lines)
If lines(i).Length > 1 Then
w.Write(lines(i))
w.Flush()
End If
Next
sw.Close()
End Sub
This code does this:
1 blah blaah blah blaah blah blaah blah blaah blah blaah 2 blah blaah blah blaah blah blaah blah blaah 3 blah blaah blah blaah blah blaah
Thanks in advance.
Last edited: