Microsoft KB Archive/180887

{|
 * width="100%"|

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

 * }

Q180887

-

The information in this article applies to:


 * Microsoft 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
There are two options for resolving this issue in the Windows CE Toolkit for Visual Basic 5.0:

Option1
Obtain the Windows CE ActiveX Control Pack available from the Microsoft Web site located at:

http://www.microsoft.com/windowsce/downloads/pccompanions/actxconpak1.asp

Option 2
Instead of checking the EOF property of the File control, use the LOC property and compare it against the LOF property. For example:

  While File1.LOC < File1.LOF 'put code here Wend

STATUS
Microsoft has confirmed this to be a problem in the Microsoft products that are listed at the beginning of this article.

This problem was corrected in Windows CE Toolkit for Visual Basic 6.0.

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:
 * 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.