0

my Do Until Loop keeps skipping the first line of my text file. I have moved the ReadLine function out of the loop and it still skips the first line. Can somebody please help me with this? The first line is not a header and I need to read it.

Sub subRunLoop
  i = 1
  CountButtonClicks = 0
  CountLoans = 0
  CountSysErrors = 0
  SuccessfulEntries = 0


  StartTime = Timer()
  strLine = objFile.ReadLine
  Do Until objFile.AtEndOfStream
            
            arrFields = Split(strLine,",")
            Number  = arrFields(0)
            subDoWork (i)                   
    
    i = i + 1
    Count = Count + 1
    
    If objFile.AtEndOfStream Then
        subWriteScriptInformation
        subWriteToScriptTracker
        subEndScript
    End If      
    Loop
End Sub
  • Any change if you initialize `i` with 0 instead of 1? – Flakes Apr 07 '21 at 13:36
  • You don't need to put ReadLine outside. Have you tried troubleshooting by checking if each line is read properly? Try putting MsgBox after ReadLine to see what is the output for each line. Other than that, your other custom functions may be doing something that is causing the issue perhaps – Pankaj Jaju Apr 07 '21 at 15:58
  • 1
    this is working now. I have placed ReadLine back inside the Loop right above the Split and changed i to 0 instead of 1 and it is now reading every line without skipping the first – UndergroundMan Apr 07 '21 at 16:11

1 Answers1

0

this is now working. placing ReadLine back in the Loop and changing i to 0 instead of 1 allows the script to read every line

Sub subRunLoop
 i = 0
 CountButtonClicks = 0
 Count = 0
 CountSysErrors = 0
 SuccessfulEntries = 0


 StartTime = Timer()
 Do Until objFile.AtEndOfStream
            strLine = objFile.ReadLine  
            arrFields = Split(strLine,",")
            subDoWork (i)                   
    
    i = i + 1
    Count = Count + 1
    
    If objFile.AtEndOfStream Then
        subWriteScriptInformation
        subWriteToScriptTracker
        subEndScript
    End If      
    Loop
End Sub