Name
FileClose Procedure
Class
Microsoft.VisualBasic.FileSystem
Syntax
FileClose([filenumber][, filenumber
][,...])
-
filenumber
Use: Optional
Data Type: 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
orAppend
, 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 theFileClose
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
Get VB .NET Language in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.