Variable length Records

ianclegg

Registered User.
Local time
Today, 18:34
Joined
Jul 14, 2001
Messages
58
HI

Can anyone help?

I have a need to read a file containing variable length records.

Each record type has an identifier as the first 3 characters of each record.

The records can contain as many as 35 fields but as few as 10


I need to write selective records to an output file

An example of the records is as below.


007,file32,R001,123,M5431
107,B,123568,23
207,ianclegg,xxx,yyy,zzz
307,1,+107.32,+91,+67,abc,hhh,fff,,,,,,,,,,68
307,2,+34.82,+65,xxx,xxx,xxx,,,,,,,,,,19
407,3,32,1
999,End,This month


I would be very grateful for any ideas


Regards


Ian Clegg
 
Ian,

Need more details, but this is a starting point.

Code:
Dim strMyArray() As String
Dim strBuffer As String
Dim intHowMany As Integer
Dim i As Integer

Dim dbs As DAO.Database
Dim rst As DAO.RecordSet

Open "C:\SomeFile.TXT" For Input As #1

Line Input #1, strBuffer
While Not EOF(1)
   strMyArray = Split(strBuffer, ",", -1)
   intHowMany = UBound(MyArray)
   rst.AddNew
   Select Case MyArray(0)
      Case "007"
         rst.AddNew
         rst!SomeField = MyArray(1)
         rst!SomeOtherField = MyArray(2)
         rst.Update
      Case "307"
         rst.AddNew
         rst!SomeField = MyArray(1)
         rst!SomeOtherField = MyArray(2)
         rst.Update
      End Select
   Wend
Close #1

Wayne
 
Variable Length Records

Thanks for the early reply.

The While/Wend did not work correctly, but the example code did enable me to fix the problem


Regards


Ian Clegg
 

Users who are viewing this thread

Back
Top Bottom