hi,
Is it possible to get the line number of a certain string in a text file, and you would do it. Also is it possible to delete a certain line from a text file, how would you code it?
Thanks for Reading this!
Printable View
hi,
Is it possible to get the line number of a certain string in a text file, and you would do it. Also is it possible to delete a certain line from a text file, how would you code it?
Thanks for Reading this!
You could open in input mode and use lineinput method to get all lines and have a counter counting them. Also you could open in binary and get a varlen string and split it into an array of lines.
Code:Dim Count As Long
Dim MyVar As String
Count = 1
Do Until EOF(FileNumber) = False
Text2.Text = Text2.Text & Count ' show the number
Line Input #FileNumber, MyVar ' put the contents into MyVar
Text1.Text = Text1.Text & vbNewLine & MyVar ' make sure multiline is true
Count = Count + 1 ' update count
Loop
this doesnt include the open and close statements..
I havent tested this code yet, so let me know if it screws up.