Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

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...
0
seckel
Asked:
seckel
  • 2
1 Solution
 
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:
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
 
EDDYKTCommented:
replace this line

for i=0 to ubound(arr)-1

to

for i=0 to ubound(arr)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now