CLOSE

CLOSE([#] [filenumber] [..])

Closes a text file or CSV file.


filenumber(Optional) The number of the file (Integer).

REMARKS
* You cannot prefix this statement with "VBA."
* The "filenumber" can be one or more file numbers (eg #12, #13, #14)
* If "filenumber" is left blank, then all files opened using the Open statement are closed.
* Closes all open files or the file specified by the "filenumber".
* You can use the OPEN statement to open a text file.
* You can use the INPUT Statement to reads data from a file and assigns the data to a list of variables.
* This function is not available in Access.
* For the Microsoft documentation refer to learn.microsoft.com

Dim iCount As Integer 
Dim sFileName As String

For iCount = 1 To 3
    sFileName = "C:\Temp\MyText" & iCount & ".txt"
    Open sFileName For Output As #iCount
    Print #iCount, "This is a test"
Next iCount

Close 2
Close (2)
Close

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top