Working with text files as objects

noccy

Registered User.
Local time
Today, 21:01
Joined
Aug 19, 2003
Messages
67
Hello!

I have recently worked with Word documents as objects in vba. I have imported data from Word to access by creating arrays.

Is there a way to work with text files using the same method?

Lets say I want to get data from a line in a text file beginning with "Test:". How to I find this line and define what data to get?

The text file might look like this:

Test: 20/11 03:13
Source: 1 Ref1:a Ref2:bc
Test: 20/11 03:13
Source: 1 Ref1:b Ref2:ce
Test: 20/11 03:13
Source: 1 Ref1:ef Ref2:f
Test: 20/11 03:13
Source: 1 Ref1:ab Ref2:b
Test: 20/11 03:13
Source: 1 Ref1:a Ref2:bc
Test: 20/11 03:13
Source: 1 Ref1:a Ref2:bcd


From this I would want to add data to a table with theese fileds:

Date, Time, Source, Ref1, Ref2

This means that Lines Starting with "Test:" means "create new record", and The data, time, source, ref1 and ref2 has to be picked from different lines. I know that Date always is character 7-11 in one line, and that Ref1 is charachter 34-38 in another line.....


Any ideas?

noccy
 
Last edited:
Look at OPEN and READ, this will allow you read through a text file
 

Users who are viewing this thread

Back
Top Bottom