Table of contents
TOC
Collapse the table of content
Expand the table of content

FileAttr Function

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Returns a Long representing the file mode for files opened using the Open statement. SyntaxFileAttr( filenumber, returntype ) The FileAttr function syntax has thesenamed arguments:

PartDescription
filenumberRequired; Integer. Any valid file number.
returntypeRequired; Integer. Number indicating the type of information to return. Specify 1 to return a value indicating the file mode. On 16-bit systems only, specify 2 to retrieve an operating system file handle. Returntype 2 is not supported in 32-bit systems and causes an error.

Return Values When the returntypeargument is 1, the following return values indicate the file access mode:

ModeValue
Input1
Output2
Random4
Append8
Binary32

Example

This example uses the FileAttr function to return the file mode and file handle of an open file. The file handle is returned only on 16-bit systems; on 32-bit systems, passing 2 as a second argument generates an error.

Dim FileNum, Mode, Handle
FileNum = 1    ' Assign file number.
Open "TESTFILE" For Append As FileNum    ' Open file.
Mode = FileAttr(FileNum, 1)    ' Returns 8 (Append file mode).
Handle = FileAttr(FileNum, 2)    ' Returns file handle.
Close FileNum    ' Close file.
© 2017 Microsoft