|
-
Jun 13th, 2000, 10:53 PM
#1
Thread Starter
Hyperactive Member
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.
-RaY
VB .Net 2010 (Ultimate)
-
Jun 13th, 2000, 10:58 PM
#2
Hyperactive Member
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
-
Jun 13th, 2000, 10:58 PM
#3
Lively Member
"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
Some cause happiness wherever they go; others, whenever they go.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|