How do I read a text file with variable length records in VB6?

I have a text file that is generated from MS-DOS. I need a VB program to read each record the text file.  The problem is that the text file contains variable length records.  How do I read a text file with variable length records?

Please show example...
seckelAsked:
Who is Participating?
 
EDDYKTConnect With a Mentor Commented:
Dim ff As Integer, s As String, arr, i
   
ff = FreeFile
Open "Filename" For Binary Access Read Lock Read Write As #ff
s = Space$(LOF(ff))
Get #ff, , s
Close ff
 
arr = split(s, vbcrlf)     ' replace vbcrlf for your delimiter
for i=0 to ubound(arr)-1
debug.print arr(i)
next

erase arr

0
 
seckelAuthor Commented:
I would like to read each record randomly, but I dont know how to get length of each record...
0
 
MADisonMANCommented:
Is there any separator in between like any char or by CR?
0
 
EDDYKTCommented:
replace this line

for i=0 to ubound(arr)-1

to

for i=0 to ubound(arr)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.