EOF While not EOF - not scan all file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gonzajm
    New Member
    • Jun 2013
    • 2

    EOF While not EOF - not scan all file

    Hi guys,
    I have a txt file that only read the first or only one line line and then skip and not scan the rest of the file. I use vb6.

    I use the following code:

    Code:
     Dim cont, n_fil As Integer
    
    Dim mivariable As String
    
    n_fil = FreeFile
    Open App.Path & "\EM.txt" For Input As #n_fil
    While Not EOF(n_fil)
    Line Input #n_fil, mivariable
    cont = cont + 1
    Wend
    
    Close #n_fil
    I attached the txt that I am using.

    Someone can help me on this please?
    Attached Files
    Last edited by Rabbit; Jun 14 '13, 07:43 PM. Reason: Please use code tags when posting code.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Actually, it's quite simple. Your input file EM.txt consists of a single record, so VB is reading it into a single string.

    I think you'll find the problem is that you only have a LF (or possibly CR) character as the record delimiter. (I don't have my usual tools available right now, or I'd have a look and tell you). VB expects the two-character pair CRLF.

    It may interest you to know that you can use the VB constants VbCR, VbLf and VbCrLf to refer to these characters.

    Comment

    Working...