Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

附註: 如果 Microsoft Jet Expression Service 在沙箱模式中執行,會停用本主題中所述的函數、方法、物件或屬性,以免評估可能不安全的表達式。 如需沙盒模式的詳細資訊,請在 [說明] 中搜尋「沙盒模式」。

傳回代表使用 Open 語句開啟之檔案之檔案模式的 Long。

語法

FileAttr ( filenumber returntype )

FileAttr 函數語法具有下列自變數:

引數

描述

filenumber

必要。 整數。 任何有效的 檔案編號。

returntype

必要。 整數。 指出要傳回之資訊類型的數位。 指定 1 以傳回指出檔案模式的值。 在僅限 16 位的系統上,指定 2 來擷取作業系統檔控點。 32 位系統不支援 returntype 2,並導致錯誤。

傳回值

returntype引數 為 1 時,下列傳回值表示檔案存取模式:

眾數

輸入

1

輸出

2

隨機

4

附加

8

二進位

32

範例

附註: 下列範例示範如何在 Visual Basic for Applications (VBA) 模組中使用此函數。 如需使用 VBA 的詳細資訊,請在 [搜尋] 旁的下拉式清單中選取 [開發人員參考],並在 [搜尋] 方塊中輸入一個或多個字詞。

此範例使用 FileAttr 函數 傳回已開啟檔案的檔案模式和檔案控點。 檔案控點只會在16位系統上傳回;在 32 位系統上,傳遞 2 做為第二個自變數會產生錯誤。

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.

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×