Results 1 to 2 of 2

Thread: File Processing

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2000
    Posts
    135
    Hi,
    Want to know how to delete a line in a file if i come across a blank line. I do not want to create a temp file doing this. I want to be able to perform any operation on the same file. Please help!!!!

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Try this:
    Code:
    Public Sub RemoveBlankLines(FileName As String)
        Dim iFile As Integer
        Dim sLines() As String
        Dim sTemp As String
        Dim iCount As Integer
        Dim i As Integer
    
        ReDim sLines(0 To 100) 
        iFile = FreeFile
        Open FileName For Input As #iFile
        Do While Not EOF(iFile)
            Line Input #iFile, sTemp
            If Len(sTemp) > 0 Then
                sLines(iCount) = sTemp
                iCount = iCount + 1
                If iCount > UBound(sLines) Then
                    ReDim Preserve sLines(0 To iCount + 100)
                End If
            End If
        Loop
        Close #iFile
        Open FileName For Output As #iFile
        For i = 0 To iCount
            Print #iFile, sLines(i)
        Next
    End Sub
    Good luck!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width