Solved

Extracting fields from a tab delimited text file in VB5

Posted on 1998-10-26
3
308 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
[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
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…
Suggested Courses
Course of the Month4 days, 21 hours left to enroll

636 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