Solved

Extracting fields from a tab delimited text file in VB5

Posted on 1998-10-26
3
297 Views
Last Modified: 2010-04-30
Hi,

I am trying to extract information from a tab delimited text file. For example the info are are organised in the following;

field1 <tab> field2 <tab> field3 <tab> field4
<blank><tab> field2 <tab><blank> <tab> field4

I can programmatically open the file in excel which is going to organise the fields in columns but I am trying to avoid that. So I am looking for a way to extract field1, field2, field3 and field4.

Anyone can help?

Regards
MMAHDI
0
Comment
Question by:mmahdi
3 Comments
 
LVL 2

Accepted Solution

by:
Poddy earned 100 total points
ID: 1441589
open the file using the open for input command
loop through the file:
  read a record in using the line input
  process the string, using instr to detect the field changes
close the file

0
 
LVL 3

Expert Comment

by:traygreen
ID: 1441590
Read through the file one character at a time looking for the tab character.

dim sChar as string
dim sField as string

Do While Not EOF(<filenumber>)
   
   sField = ""
   sChar = Input(1,<filenumber>)

   Do While sChar <> chr(9)   ' 9 = tab
      sField = sField & sChar
      sChar = Input(1,<filenumber>)
   Loop
   
   ' Do Something with sField (ie set variable etc)
   
Loop
0
 
LVL 1

Author Comment

by:mmahdi
ID: 1441591
It worked great! Thanks for your valuable help.

Regards
mmahdi
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now