LibreOffice 25.2 Help
Trả về chế độ truy cập hoặc số truy cập tập tin của một tập tin đã được mở bằng câu lệnh Open. Số truy cập tập tin cũng phụ thuộc vào hệ điều hành (OSH: bộ quản lý hệ điều hành).
If you use a 32-Bit operating system, you cannot use the FileAttr function to determine the file access number.
Xem thêm: Open
  FileAttr (Channel As Integer, Attributes As Integer)
Số nguyên
Channel: The number of the file that was opened with the Open statement.
Attributes: Integer expression that indicates the type of file information that you want to return. The following values are possible:
1: FileAttr indicates the access mode of the file.
2: FileAttr returns the file access number of the operating system.
Ghi rõ một thuộc tính tham số có giá trị 1 thì trả về các giá trị này:
1 - NHẬP (tập tin mở để nhập vào)
2 - XUẤT (tập tin mở để xuất ra)
4 - NGẪU NHIÊN (tập tin mở để truy cập ngẫu nhiên)
8 - PHỤ THÊM (tập tin mở để phụ thêm)
32 - NHỊ PHÂN (tập tin mở ở chế độ nhị phân).
Sub ExampleFileAttr
    Dim iNumber As Integer
    Dim sLine As String
    Dim aFile As String
    aFile = "C:\Users\ThisUser\data.txt"
    iNumber = Freefile
    Open aFile For Output As #iNumber
    Print #iNumber, "This is a line of text"
    MsgBox FileAttr(#iNumber, 1), 0, "Access mode"
    MsgBox FileAttr(#iNumber, 2), 0, "File attribute"
    Close #iNumber
End Sub