I have done a lot of searching for a code sample of reading a file line by line and extracting text based on its position but haven't come up with anything usefull. I can read each line with this:
I have a text file that has no visable delimiter like a comman etc. The coloulmns are determined by the position in the file. For instance:Code:' Need to find the 1st and 10th position in the sample ' text file. Private Sub ReadFile() Dim oread As StreamReader = _ File.OpenText("C:\sample.txt") While oread.Peek <> -1 Debug.Write(oread.ReadLine() & vbNewLine) End While oread.Close() End Sub
1 2 3 4 5 6 7 8 9
----------------
M i k e S m i t h
The first name starts at position 1 and the last name starts at position 5 (I don't think it will line up right in the mock up above but that is the idea). Does anybody have a sample peice of code they could point me to?




Reply With Quote