BUG: Input Function Doesn't Ignore EOFLast reviewed: February 26, 1996Article ID: Q140354 |
The information in this article applies to:
SYMPTOMSWith Visual Basic 4.0, code that uses the Input$ function and assumes that Visual Basic will return an empty value if input is attempted past the end of file fails. This code returns run-time error number 62 - "Input past end of file". If run with Visual Basic 3.0, no error is received.
WORKAROUNDUsers should not assume that Visual Basic will return an empty value if a program attempts to access a file location that doesn't exist because it is past the end of file location. The Lof function can be used to determine the length of a file, and no input should be attempted past this value. To fix code that currently does this, an explicit check for the end of file can be added before attempting to read data. This can be performed by using the Loc and Lof functions to check whether the file location (Loc) after an upcoming read will be greater than the length of file (Lof). The example below includes code that implements this fix.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching the problem and will post more information here in the Microsoft Knowledge Base when it is available.
MORE INFORMATION
Steps to Reproduce
REFERENCESFor additional information, please see the following article in the Microsoft Knowledge Base: ARTICLE-ID: Q142246 TITLE : BUG: Sequential File I/O Does Not Handle Embedded Nulls |
Additional reference words: buglist4.00 4.00 vb4all vb4win
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |