Results 1 to 10 of 10

Thread: EOF Question

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    7
    Hi,
    here's my code
    Open (txtpath.Text) For Input As #1
    Open "a:\temp.txt" For Output As #2
    sSearch = txtSstr.Text
    isearch = Len(sSearch)
    sreplace = txtRstr.Text
    ireplace = Len(sreplace)

    Line Input #1, sInput
    Do
    iPos = InStr(1, sInput, sSearch)
    If (iPos <> 0) Then
    iCount = iCount + 1
    sInput = Right(sInput, Len(sInput) - iPos)

    Else
    Line Input #1, sInput

    End If

    Loop While (Not EOF(1))

    lblIcount.Caption = "The total of strings found and replaced = " & CInt(iCount)

    Close #1
    Close #2

    it seems that the loop exits before reading the last line, I've tried moving the EOF to the do but it does the same thing, and help would be apprecated.

  2. #2

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    7

    EOF

    Martin,
    tried that but works the same, Thanks Anyway

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    if not eof(1) Line Input #1, sInput

    at the first line input statemnt
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Guest
    Try this:

    Do While Not EOF(1)
    '
    Loop

  6. #6
    Guest
    That's the same as MartinLiss's except it's a Do Loop.

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    HAha why don't you just suggest Do Until EOF(1) insteaD?
    I thought you guys were smarter than that, but actually i think the problem is something else, namely the file isn't in ascii text, but binary data which causes input to read the eof long before the real end of file.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Guest
    <-was tired when he posted.

    Sorry, you know what it's like kedaman, when your tired .

    Originally posted by kedaman
    HAha why don't you just suggest Do Until EOF(1) insteaD?
    I thought you guys were smarter than that, but actually i think the problem is something else, namely the file isn't in ascii text, but binary data which causes input to read the eof long before the real end of file.

  9. #9
    Guest
    Kedaman-> They both do the same thing.

  10. #10
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Yeah i know exactly what it's like when i'm tired
    Do while not not not not not not not not not not not not not not not not not not not not not not not not not not not not not not not not not not Eof(1)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width