FIX: File Control's EOF Property Is Always Set to FalseID: Q180887
|
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:
-or-An error was encountered while running this program.
-2147467259
The file EOF property is not set to True when the file pointer reaches the end of the file.
There are two options for resolving this issue in the Windows CE Toolkit for Visual Basic 5.0:
While File1.LOC < File1.LOF
'put code here
Wend
Microsoft has confirmed this to be a problem in the Microsoft products listed
at the beginning of this article.
This problem was corrected in Windows CE Toolkit for Visual Basic 6.0.
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
Books Online for Microsoft Windows CE Toolkit for Visual Basic 5.0
Additional query words: wce vbce vbce5 vbce6
Keywords : kbToolkit kbVBp kbVBp500bug kbVBp600fix kbWinCE kbWinCE100 kbGrpVB
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: July 14, 1999