-
Ok this reads line 1 on a text file
Open "c:\yourfile.txt" For Input As #1
Dim sFirst
Line Input #1, sFirst
If sFirst = "yes" Then
Label1.Visible = True
Else
Exit Sub
End If
Close #1
y when i switch line input#1 to 2 it doesnt read line 2? How would i go about change it to line 2.
-
open question
The #1 stands for the FileNumber that you are accessing not the line #. If you want to get more lines add more line inputs like so:
Open "c:\yourfile.txt" For Input As #1
Dim sFirst, sSecond, sThird, sFourth
Line Input #1, sFirst
Line Input #1, sSecond
Line Input #1, sThird
Line Input #1, sFourth
If sFirst = "yes" Then
Label1.Visible = True
Else
Exit Sub
End If
Close #1
...later
mikeF
-
"Line Input #1" means read a line from file with file descriptor number 1...to read the second line, just call it again. While we're on the subject, you should really get a free file descriptor using FreeFile(), as in:
Code:
Dim FNUM as Integer
FNUM=FreeFile()
Open "C:\whatever.txt" For Input Access Read As #FNUM
...
then you'll never have a problem reading the wrong file.
HTH,
Toot