Reading from a file

rodneyb

Registered User.
Local time
Today, 13:33
Joined
Jul 3, 2003
Messages
84
I have this command which reads each line in a file:

Dim message as String
Open filename For Input Access Read As #1
Do While Not EOF(1)
Input #1, message
'do stuff with message
Loop
Close #1

The message String will look something like this:
CP_FCPS_BOOK<FS>11<FS>AP<FS>112563<FS><LF>

where <FS> is a field separator and <LF> is the end of the line.

Each field in the line has a specific length but not necessarily the fixed length allocated. ie CP_FCPS_BOOK may be allocated 20 char length but in this case is only 12 char long.

My question is how can I separate each field from the 'message' string?
 
Code:
Dim MyVar as variant

MyVar = Split(message,"<FS>")

This will create an array of elements based upon your <FS> delimiting in MyVar.

HTH,
Patrick
 
Thanks PIM,

I have inserted the code you provided but an error occurs on 'Split' saying Sub or Function not defined.

I am using Access97, is this the reason why 'Split' does not work?

After further investigating I found after searching the web using these key words: "Simulate Visual Basic 6.0 String Functions in VB5"

The corresponding website had some code which I applied to mine which solves my problem.

Cheers
 
Last edited:

Users who are viewing this thread

Back
Top Bottom