Hello,
It is possible to obtain the number of records in a random access file using this code:
This is fine, but how can I obtain the number of lines in a text input file, so I can read a random line from the file, eg:
I suppose I should have asked, How can I get a random line from a file, without knowing how many lines are in the file? [Thanks in advance|Hope I helped you]
Exodus300
World-Wide Alliance of Evil and Twisted People
[red]"Experimentation by Example is the best learning tool" - Exodus300[/red]
![[pc3] [pc3] [pc3]](/data/assets/smilies/pc3.gif)
It is possible to obtain the number of records in a random access file using this code:
Code:
Open "C:\abc.dat" For Random As 1 Len = Len(MyRecord)
NumRecords = LOF(1) \ Len(MyRecord)
Code:
Dim L As Integer, I As Integer, TempLine As String
Open "C:\abc.txt" For Input As 1
NumLines = ????? ' What to put here?
L = Int(Rnd * NumLines) + 1
For I = 1 To L
Line Input #1, TempLine
Next
' Now, TempLine contains a random line from the file
I suppose I should have asked, How can I get a random line from a file, without knowing how many lines are in the file? [Thanks in advance|Hope I helped you]
Exodus300
World-Wide Alliance of Evil and Twisted People
[red]"Experimentation by Example is the best learning tool" - Exodus300[/red]
Code:
if (pop_tarts == 0)
{
tantrum = 1;
}
![[pc3] [pc3] [pc3]](/data/assets/smilies/pc3.gif)