CodeItBetter Programming Another VB Programming Blog

How to Delete a specific line from a file (note: first line = line number 0)

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
'Text File Handling - How to Delete a specific line from a file (note: first line = line number 0)
Private Sub deleteLine(ByVal strFile As String, ByVal lineNumber As Long)
    Dim strArrBuff() As String, i As Long
    Open strFile For Input As #1
    strArrBuff() = Split(Input(LOF(1), 1), vbCrLf)
    Close #1
    Open strFile For Output As #1
    For i = 0 To UBound(strArrBuff)
        If Not i = lineNumber Then Print #1, strArrBuff(i)
    Next
    Close #1
End Sub
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.