Solved

Extracting fields from a tab delimited text file in VB5

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

831 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