CodeItBetter Programming Another VB Programming Blog

How to Remove all empty lines from the text file

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'Text File Handling - How to Remove all empty lines from the text file
Option Explicit
 
Sub RemoveAllEmptyLinesFromTextFile(ByVal sFile As String)
    Dim sLine As String, sContents As String
    Open sFile For Input As #1
    While Not EOF(1)
        Line Input #1, sLine
        If Not sLine = vbNullString Then
            If EOF(1) Then
                sContents = sContents & sLine
            Else
                sContents = sContents & sLine & vbCrLf
            End If
        End If
    Wend
    Close #1
    Open sFile For Output As #1
    Print #1, sContents
    Close #1
End Sub
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.