1 line at a time ::RESOLVED::
Hi
Can anyone show me how to get a line out from a text file 1 at a time for processing.
For example, This text file can have a variable number of lines. I want to be able to press a commandbutton which gets the first line from the text file and displays it in a textbox.
If I press the commandbutton a second time, the program gets the second line out and displays it the same way as above.
Then the third line and so on until it reaches the end and stops.
I think the EOF will need to be used.
please help :confused:
This might be a late reply
This could be a late reply, but i think this is what you want???
Button:Command1
ListBox:Listbox1
Code:
Option Explicit
Private Sub Command1_Click()
Static i As Integer, j As Integer, strData As String
j = j + 1
Open "C:\YourTextFile.txt" For Input As #1
For i = 1 To j
Line Input #1, strData
Next i
List1.AddItem strData
Close #1
End Sub
The first time you click it will only add the first line of the text file to the list box. On the 2nd time you click the button it will only add the 2nd line of the file to the list box (the first line from the text file is already there from the first time you clicked??)
If u need more help, don't hesitate...