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 語句 可用之下一個 檔案編號 的整數。

語法

FreeFile[ (rangenumber) ]

選擇性 rangenumber 自變數 是 Variant,可指定要傳回下一個免費檔案號碼的範圍。 指定 0 (預設) 傳回範圍為 1 - 255,含的檔案編號。 指定 1 可傳回範圍為 256 – 511 的檔案號碼。

註解

使用 FreeFile 提供尚未使用的檔案號碼。

範例

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

此範例使用 FreeFile 函數傳回下一個可用的檔案編號。 系統會開啟五個檔案以便在迴圈中輸出,而某些範例數據會寫入每一個檔案。

Dim MyIndex, FileNumber
For MyIndex = 1 To 5 ' Loop 5 times.
' Get unused file number.
FileNumber = FreeFile
' Create file name.
Open "TEST" & MyIndex For Output As #FileNumber
' Output text.
Write #FileNumber, "This is a sample."
' Close file.
Close #FileNumber
Next MyIndex

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!

×