Visual Basic Language Reference  

FileAttr Function

Returns an enumeration representing the file mode for files opened using the FileOpen function.

Public Function FileAttr(ByVal FileNumber As Integer) As OpenMode

Parameter

FileNumber
Required. Integer. Any valid file number.

Exceptions/Errors

Exception type Error number Condition
IOException 52 FileNumber does not exist.
IOException 54 File mode is invalid.

Return Values

The following enumeration values indicate the file access mode:

Value Mode
1 OpenMode.Input
2 OpenMode.Output
4 OpenMode.Random
8 OpenMode.Append
32 OpenMode.Binary

Example

This example uses the FileAttr function to return the file mode of an open file.

Dim mode As OpenMode
FileOpen(1, "c:\MYFILE.TXT", OpenMode.Input)
mode = FileAttr(1)
MsgBox("The file mode is " & mode.ToString())
FileClose(1)

See Also

GetAttr Function | FileOpen Function | SetAttr Function | IOException