Close Statement

 

Close [[#filenumber] [, [#]filenumber],,,

 

The Close Statement takes one argument filenumberFilenumber  is the number used with the Open Statement to open the file.  If the Close Statement is used without any arguments it closes all open files.

 

Example:

 

Sub Main

Open "c:\test.txt" For Input As #1

Do While Not EOF(1)

   MyStr = Input(10, #1)

   MsgBox MyStr

Loop

Close #1

 

End Sub

 

 

Sub Make3Files ()

   Dim I, FNum, FName   ' Declare variables.

   For I = 1 To 3

       FNum = FreeFile  ' Determine next file number.

       FName = "TEST" & FNum

       Open FName For Output As FNum  ' Open file.

       Print #I, "This is test #" & I ' Write string to file.

       Print #I, "Here is another ";  "line";  I

   Next I

   Close  ' Close all files.

End Sub