ive looked for this and the basic code for inputs but it doesnt have anything about this
example: say my file looks like this
-------------
yes
no
1
14
-------------
can i get just the 3rd line to get the number 1?
code would help too
I don't think there's any simple way to jump directly to the third line, unless they are fixed-length records (which doesn't appear to be the case). This code should produce the desired end, though. I'm assuming we're dealing with VB6, because (A) you didn't say, and (B) that's what I'm familiar with. :)
Also, the code is a little longer than strictly necessary, as I've tried to make it more generally applicable rather than just hard-coding everything. For instance, you can change which line by varying the value of
LinesToSkip.
-
Dim FileNum As Long
-
Dim LinesToSkip As Long
-
Dim Text As String
-
LinesToSkip = 2
-
FileNum = FreeFile ' Get next available file number.
-
Open "TheFile.txt" For Input Access Read Shared As #FileNum
-
For I = 1 To (LinesToSkip + 1)
-
Line Input #FileNum, Text
-
Next
-
Close FileNum
-
' You now have the third line in Text.
-
also what is the command to stop the program when it becomes unresponsive (like when u have an enless loop)
Not sure exactly what you mean. If you're in the IDE, then you can just click the stop or pause button, or hit Ctrl-Break to interrupt. I don't think there is anything your program can easily do about the situation.
Except to
stop looping, I suppose. :)
If you are executing compiled code and it doesn't provide any way to stop it, then you can use the Windows task manager to kill it.