BUG: File Control's EOF Property Is Always Set to False

Last reviewed: February 11, 1998
Article ID: Q180887
The information in this article applies to:
  • Windows CE Toolkit for Visual Basic 5.0, version 1.0

SYMPTOMS

When using the File Control and reading from a file using either the LineInputString or InputFields methods, the EOF property is always False, even when it has reached the end of the file. One of the following error messages will be generated:

   An error was encountered while running this program.

   -or-

   -2147467259

CAUSE

The file EOF property is not set to True when the file pointer reaches the end of the file.

RESOLUTION

Check for the error immediately following the LineInputString or InputFields method and handle it accordingly. See the MORE INFORMATION section below for details.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Behavior

NOTE: This example uses the LineInputString method. The error also occurs using the InputFields method.

  1. Start a new Windows CE project in Visual Basic 5.0. Form1 is created by default.

  2. Add a File control, two CommandButton controls and a TextBox to Form1.

  3. Set the Text1.Multiline property to True.

  4. Add the following code:

          Option Explicit
    

          Private Sub Form_Load()
    
             Command1.Caption = "Write to file"
             Command2.Caption = "Read from File"
          End Sub
    
          Private Sub Command1_Click()
             'Write file via LinePrint
             File1.Open "\test.txt", 2
             File1.LinePrint "line one"
             File1.LinePrint "line two"
             File1.LinePrint "line three"
             File1.Close
          End Sub
    
          Private Sub Command2_Click()
             'Read file via LineInputString
             Dim sLine
             On Error Resume Next
             Text1.Text = ""
             File1.Open "\test.txt", 1
             Do Until File1.EOF
                sLine = File1.LineInputString
                If Err.Number <> 0 Then
                   Text1.Text = Text1.Text & "error: " & _
                   Err.Number & " " & Err.Description & vbCrLf
                   File1.Close
                   Exit Sub
                End If
                Text1.Text = Text1.Text & sLine & ":  File1.EOF = " _
                             & File1.EOF & vbCrLf
             Loop
             File1.Close
          End Sub
    
    

  5. Press the F5 key to run the project and note that the error -2147467259 is encountered because File1.EOF is never set to True.

REFERENCES

Books Online for Microsoft Windows CE Toolkit for Visual Basic 5.0


Additional query words: wce
Keywords : vb5all vbce kberrmsg
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbpending


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 11, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.