Table of contents
TOC
Collapse the table of content
Expand the table of content

Close Statement

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Concludes input/output (I/O) to a file opened using the Open statement.

Syntax

Close [ filenumberlist ]

The optional filenumberlistargument can be one or morefile numbers using the following syntax, where filenumber is any valid file number: [[ # ] filenumber ] [ , [ # ] filenumber ] . . .Remarks If you omit filenumberlist, all active files opened by the Open statement are closed. When you close files that were opened for Output or Append, the final buffer of output is written to the operating system buffer for that file. All buffer space associated with the closed file is released. When the Close statement is executed, the association of a file with its file number ends.

Example

This example uses the Close statement to close all three files opened for Output.

Dim I, FileName 
For I = 1 To 3 ' Loop 3 times. 
 FileName = "TEST" &; I ' Create file name. 
 Open FileName For Output As #I ' Open file. 
 Print #I, "This is a test." ' Write string to file. 
Next I 
Close ' Close all 3 open files. 
© 2017 Microsoft