I'm not sure how to go about doing this. I know how to read from a textfile and write to a text delimited file, but I need to be able to extract specific data from the text file that I'm reading and not sure how to go about doing that. Here's an example of the file that I'm reading from and then an example of what data it is extracting and write to 3 text delimated files.

Text file to read from:

VB Code:
  1. CDL8GL02122 PR045050000012345   CHECKS          03
  2. CDL8GL02322 PR045050000234334   DED B           03
  3. CDL8GL09323 PR045050008821677   LTD         03
  4. CDL8GL50203-30  PR045050003239083   REGULAR EARNINGS    03
  5. CDL8GL50203-44  PR045050000022234   DED 29          03
  6. CDL8GL51232-51  PR045050000776757   DED 29          03
  7. CDL8GL52332-32  PR045050002343234   VOLUNTARY LIFE      03
  8. CDL8GL52332-31  PR045050003587821   REGULAR EARNINGS    03
  9. CDL8GL52332-33  PR045050002324879   REGULAR EARNINGS    03
  10. CDL8GL52332-34  PR045050022387767   REGULAR EARNINGS    03
  11. CDL8GL60923-23  PR045050000589876   VOLUNTARY LIFE      03
  12. CDL8GL70934-22  PR045050000334452   VOLUNTARY LIFE      03
  13. CDL8GL70983-25  PR045050000234323   DED 29          03

After reading it from the source textfile, it will write it into 3 different files depending what is from the source textfile.

VB Code:
  1. File#1
  2. 2122        ADP 0450    0         123.45
  3. 2322        ADP 0450    0        2343.34
  4. 9323        ADP 0450    0       88216.77
  5. 70983-25    ADP 0450    2343.23            0
  6. 70934-22    ADP 0450    3344.52            0
  7.  
  8.  
  9. FILE#2
  10. 50203-30    ADP 0450    32390.83           0
  11. 50203-44        ADP 0450          222.34           0
  12. 51232-51    ADP 0450     7767.57           0
  13. 52322-32    ADP 0450    23432.34           0
  14. 52322-31    ADP 0450           0    35878.21
  15.  
  16.  
  17. FILE#3
  18. 63223-33    ADP 0450    23248.79           0
  19. 62332-34    ADP 0450       223877.67           0
  20. 60923-23    ADP 0450           0     5898.76

What I need help with is how would I trim each line so that it would pull specific data from the source file per line and then write it to a text delimited file depending on what is the account number? The account number from the above example are the ones beginning with "CDL" and will always stay like that.

I was thinking about reading it to an array and then trim each strings, but I'm not really sure. I need to be able to put these into each cell within a row from the text delimited file. Can someone with experience help guide me on what's the best approach? Let me know if you need more details.

Thanks,

Chris