-
Lines in text file
Hey, I need to load text from a textbox into my vb6 form but the thing is I want to you use a timer that loads the 1st line of text then makes the Text1.text = to that 1st line in the file. Then after the timer runs again it should do that same but just load the 2nd line ...ect. It should stop when it's at the end of file.
-
I would declare a module-level variable to hold the file handle and open the file when the app starts. Then in the Timer event, simply read a line from the file:
Code:
' hFile is your module-level handle variable
Line Input #hFile, sText
Text1.Text = sText
-
and do not forget to disable the timer and close the file at EOF...
Replace
Text1.Text = sText
with
Text1.SelStart = len(text1.text) <= put the insertion point at the end of the text box
Text1.selText = sText <= add a new line
Marco