troubleshooting Question

Reading text file with cr\lf\eof

Avatar of gnixon14
gnixon14Flag for United States of America asked on
.NET ProgrammingVisual Basic.NETMicrosoft Development
7 Comments1 Solution631 ViewsLast Modified:
I'm attempting to read a txt file with the following data.

00000927600000005DOE,JOHN M                                      MW04/20/1963 38GRNBRO000000000000000000  -                  2555 9TH ST                   MONROE              WI53566    (000) 000-0000(000) 000-0000                                                                                A000001550                                                                                                                                                                                                                                                                                                                                                                                                                                           JULES,                                       SMITH, BO/LEE                                00000000000                                  00000000000                                  XXXXX11306/28/00


the weird symbol there is a eof marker that ibm places in the txt file.

This is my code:
Public Sub ExtractStuff(path__1 As String, FSGUser As String)
        Dim FYWTO As String = String.Empty
        Dim FSGU As String = String.Empty
        FSGU = FSGUser
        FYWTO = path__1
        Try

            Dim DSource As String
            Dim ICatalog As String
            Dim UserID As String
            Dim Password As String
            Dim appstring As String
            Dim ip As String
            Dim port As String
            Dim agency As String
            Dim appcode As String
            Dim scramblekey As String
            ConfigReader.CR(DSource, ICatalog, UserID, Password, appstring, ip, port, agency, appcode, scramblekey)

            Dim objReader As StreamReader = New StreamReader(FYWTO)
            Dim strLine
            Dim dsK1 As String  'Key 1
            Dim dsK2 As String  'Key 2
            Dim dsNam As String  'Name
            Dim dsSex As String  'sex
            Dim dsRac As String  'race
            Dim dsDoB As String  'date of birth
            Dim dsAge As String  'age
            Dim dsEye As String  'eye color
            Dim dsHar As String  'hair color
            Dim dsHgt As String  'height
            Dim dsWgt As String  'weight
            Dim dsSSN As String  'Social Security Numbedr
            Dim dsDLN As String  'Driver License Number
            Dim dsADR As String  'Address
            Dim dsCty As String  'City
            Dim dsSta As String  'State
            Dim dsZip As String  'Zip
            Dim dsHPh As String  'Home Phone
            Dim dsWPh As String  'Work Phone
            Dim dsEmp As String  'Employer
            Dim dsOcc As String  'Occupation
            Dim dsFBI As String  'FBI
            Dim dsSID As String  'SID
            Dim dsLoc As String  'Loc
            Dim dsMis As String  'Mis
            Dim dsRW1 As String  'RW1
            Dim dsRW2 As String  'RW2
            Dim dsRW3 As String  'RW3
            Dim dsRW4 As String  'RW4
            Dim dsCt1 As String  'Cont1
            Dim dsCt2 As String  'Cont2
            Dim dsCt3 As String  'Cont3
            Dim dsCt4 As String  'Cont4
            Dim dsCt5 As String  'Cont5
            Dim dsMDt As String  'Mdate
            Dim dsAk1 As String  'AKA1
            Dim dsAk2 As String  'AkA2
            Dim dsSM1 As String  'SMT1
            Dim dsSM2 As String  'SMT2
            Dim dsCll As String  'Cell
            Dim dsLkr As String  'Lkr
            Dim dsBkD As String  'BookD

            Do While Not objReader.EndOfStream

                strLine = objReader.ReadLine()
                dsK1 = strLine.Substring(0, 9) 
                dsK2 = strLine.Substring(9, 8) 
                dsNam = strLine.Substring(17, 50)
                dsSex = strLine.Substring(67, 1) 
                dsRac = strLine.Substring(68, 1) 
                dsDoB = strLine.Substring(69, 10) 
                dsAge = strLine.Substring(79, 3) 
                dsEye = strLine.Substring(82, 3) 
                dsHar = strLine.Substring(85, 3) 
                dsHgt = strLine.Substring(88, 4) 
                dsWgt = strLine.Substring(92, 3)
                dsSSN = strLine.Substring(95, 11) 
                dsDLN = strLine.Substring(106, 21) 
                dsADR = strLine.Substring(127, 30) 
                dsCty = strLine.Substring(157, 20) 
                dsSta = strLine.Substring(177, 2) 
                dsZip = strLine.Substring(179, 9) 
                dsHPh = strLine.Substring(188, 14) 
                dsWPh = strLine.Substring(202, 14) 
                dsEmp = strLine.Substring(216, 30) 
                dsOcc = strLine.Substring(246, 30) 
                dsFBI = strLine.Substring(276, 10) 
                dsSID = strLine.Substring(286, 10) 
                dsLoc = strLine.Substring(296, 10) 
                dsMis = strLine.Substring(306, 12) 
                dsRW1 = strLine.Substring(318, 45) 
                dsRW2 = strLine.Substring(363, 45) 
                dsRW3 = strLine.Substring(408, 45) 
                dsRW4 = strLine.Substring(453, 45) 
                dsCt1 = strLine.Substring(498, 45) 
                dsCt2 = strLine.Substring(543, 45) 
                dsCt3 = strLine.Substring(588, 45) 
                dsCt4 = strLine.Substring(633, 45) 
                dsCt5 = strLine.Substring(678, 45) 
                dsMDt = strLine.Substring(723, 10) 
                dsAk1 = strLine.Substring(733, 45) 
                dsAk2 = strLine.Substring(778, 45) 
                dsSM1 = strLine.Substring(823, 45) 
                dsSM2 = strLine.Substring(868, 45) 
                dsCll = strLine.Substring(913, 5) 
                dsLkr = strLine.Substring(918, 3)
                dsBkD = strLine.Substring(921) 
            Loop

The hex 1A is throwing this error.
index and length must refer to a location within the string. paramter name: length
How do I remove or ignore the eof marker? This has been driving me insane.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros