Solved

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

Posted on 2004-03-29
4
286 Views
Last Modified: 2012-05-04
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
Comment
Question by:seckel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:seckel
ID: 10706016
I would like to read each record randomly, but I dont know how to get length of each record...
0
 
LVL 1

Expert Comment

by:MADisonMAN
ID: 10706224
Is there any separator in between like any char or by CR?
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 500 total points
ID: 10706329
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
 
LVL 26

Expert Comment

by:EDDYKT
ID: 10706358
replace this line

for i=0 to ubound(arr)-1

to

for i=0 to ubound(arr)
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 3 hours left to enroll

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question