FileClose Procedure

   
FileClose Procedure

Class

Microsoft.VisualBasic.FileSystem

Syntax

 FileClose([   filenumber   ][,   filenumber   ][,...]) 
filenumber (optional; Integer)

The file number (or numbers ) of an open file (or files), opened using the FileOpen procedure

Description

Closes one or more files opened with the FileOpen procedure

Rules at a Glance

  • If filenumber is omitted, all open files are closed.

  • If the file you are closing was opened for Output or Append , the remaining data in the I/O buffer is written to the file. The memory buffer is then reclaimed.

  • When the FileClose procedure is executed, the file number used is freed for further use.

  • filenumber can either be a literal number, a numeric constant, or a numeric variable.

Programming Tips and Gotchas

  • With the FileClose procedure, you can close more than one file at once by specifying the file numbers as a comma-delimited list, as shown here:

     FileClose(1, 3, 4) 
  • The FileClose procedure does not check first to see if there is a file associated with the given file number. Therefore, no error occurs if you use the FileClose procedure with a nonexistent file number. The drawback to this is that you may inadvertently think you have closed a file, when in fact you haven't.

VB.NET/VB 6 Differences

FileClose is new to VB.NET. It replaces the Close statement in VB 6.

See Also

FileOpen Procedure, Reset Procedure

   


VB.Net Language in a Nutshell
VB.NET Language in a Nutshell
ISBN: B00006L54Q
EAN: N/A
Year: 2002
Pages: 503

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net