BUG: Input Function Doesn't Ignore EOF (140354)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Standard Edition for Windows 3.0
- Microsoft Visual Basic Professional Edition for Windows 3.0
This article was previously published under Q140354 SYMPTOMS
With 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.
WORKAROUND
Users 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.
STATUS
Microsoft 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.
REFERENCES
For additional information, please see the following article in the
Microsoft Knowledge Base:
142246 BUG: Sequential File I/O Does Not Handle Embedded Nulls
Modification Type: | Minor | Last Reviewed: | 1/8/2003 |
---|
Keywords: | kbbug KB140354 |
---|
|