Siebel VB Language Reference > VB Language Reference >
FileAttr Function
This standard VB function returns the file mode or the operating system handle for an open file. Syntax
FileAttr(filenumber, returntype)
|
|
filenumber |
The file number used in the Open statement to open the file |
returntype |
An integer representing the type of information to return |
Returns
|
|
1 |
The file mode of the open file, where
- 1 indicates Input mode
- 2 indicates Output mode
- 8 indicates Append mode
|
2 |
The operating system handle of the open file |
Usage
The argument filenumber is the number used in the Open statement to open the file. Example
This example closes an open file if it is open in input or output mode. If open in append mode, it writes a range of numbers to the file. The second subprogram, CreateFile , creates the file and leaves it open. (general) (declarations) Option Explicit Declare Sub CreateFile
Sub CreateFile Rem Put the numbers 1-10 into a file Dim x as Integer Open "c:\temp001" for Output as #1 For x = 1 to 10 Write #1, x Next x End Sub
Sub Button_Click Dim filemode as Integer Dim attrib as Integer Call CreateFile attrib = 1 filemode = FileAttr(1,attrib) If filemode = 1 or 2 then Close #1 Else For x = 11 to 15 Write #1, x Next x Close #1 End If Kill "c:\temp001" End Sub
See Also
GetAttr Function Open Statement SetAttr Statement
|