I would have two lists or arrays that mirror your two files. Arrays have the advantage that the index is known, eg if you have an array of five descriptors for five fields, then the first field is index 0, the second field is index 1, ... the last field is index 4 (= the five fields - 1).
Or you could use a map, with the field number as the key, eg:
Type FieldDescriptorType( _
FNumber As Int, _
FName As String, _
FType As String, _
FLength As String, _
DecimalPlaces As Int _
)
and then read the LAYOUT file line by line (skipping the header line, or using it to confirm that the file has the expected columns), and fill in the descriptor fields accordingly, including implied lengths eg:
- date is 8 or 10 or 11 characters (yyyymmdd, dd/mm/yy, dd-mmm-yyyy ?)
- 3.2 decimal is 6 characters, or maybe 7 characters if the +/- sign is not included in the 3.
Once you've filled out the FieldDescriptor Map, then (i) you know how many fields are in each record (FieldDescriptor.Length) and (ii) you can calculate the fixed record length of the DATA file, by summing the field lengths:
Dim RecordLength As Int = 0
For Each fd As FieldDescriptorType In FieldDescriptorMap 'doesn't matter which order they're summed in
RecordLength = RecordLength + fd.FLength
Next
And then "all you have to do is" stroll through the DATA file reading RecordLength-byte blocks and splitting them up according to the FLengths, interpreting each field according to its FType and adding them to an array, and then adding the completed array to a List of records.
On a related note: old DBF files have a structure similar to having your LAYOUT + DATA files but as a single file, and can be read by most spreadsheet programs.