Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-03-29
4
Medium Priority
?
288 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

704 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