Close (statement)

<< Click to Display Table of Contents >>

Close (statement)

Close [[#]FileNumber]

Closes a specific open file or all open files.

FileNumber is the number assigned to the file by the Open statement. If you omit it, all currently open files will be closed.

See also: Open

Example:

Sub Make3Files

 Dim i, FNum, Fname

 For i = 1 To 3

         FNum = FreeFile                   ' Retrieve a free file index

         FName = "TEST" & FNum

         Open FName For Output As Fnum     ' Open file

         Print #i, "This is test #" & i   ' Write to file

         Print #i, "One more line"

 Next i

 ' Close all files

 Close

End Sub