Say I have a text document called TEXT
it's a *.txt file.
if I wanted to grab all of the text on a specific line say...line 1, how would I do this with VB?
I would want to put it to a string variable.
Printable View
Say I have a text document called TEXT
it's a *.txt file.
if I wanted to grab all of the text on a specific line say...line 1, how would I do this with VB?
I would want to put it to a string variable.
simple as pie ok lets say the file path is selected from cd1.filename heres the codeQuote:
Originally Posted by Zlord
VB Code:
private sub command1_click dim temp as string dim filestuff() as string Fno = FreeFile Open cd1.FileName For Input As Fno temp = Input$(LOF(Fno), Fno) Close #Fno filestuff() = split(temp,vbnewline) temp = filestuff(0) End Sub
this code opens the file puts it into temp splits it on everyline then temp becomes the first line or for lines u do stuff like filestuff(0 to how many lines)
hope this helped:)
CD1.filename?
No clue what you're talking about;
I don't see why you have to read all the file when you only need the first line. It saves using LOF and Split. It reads the first line from the file and puts this into Text1.Text. ;)VB Code:
Dim FileIn As String Open "C:\Text.txt" For Input As #1 ' Open file for input. Line Input #1, FileIn ' Read line of data. Text1.Text = FileIn Close #1 ' Close file.
um he was using line1 as an example but anyways cd1.filename is commondialog1 just the name is changed so less typing involvedQuote:
Originally Posted by Keithuk