Close
Stream I/O function to terminate access to a device
Syntax
`
result = Close [[#]filenum ] [, [#]filenum ...]
or
Close [[#]filenum ] [, [#]filenum ...]
`
Parameters
`filenum`
List of file numbers to close.
Description
Closes the files whose file numbers are passed as arguments. If an unused file number is passed, `Close` returns an error.
`Close` without arguments closes all the files presently opened.
Terminating the program using an `End` statement will automatically close all files.
Return Value
`Close` returns zero (`0`) on success and a non-zero error code otherwise.
Example
`
' Create a string and fill it.
Dim buffer As String, f As Integer
buffer = "Hello World within a file."
' Find the first free file number.
f = FreeFile
' Open the file "file.ext" for binary usage, using the number "f".
Open "file.ext" For Binary As #f
' Place our string inside the file, using number "f".
Put #f, , buffer
' Close the file. We could also do 'Close #f', but it's only necessary if more than one number is open.
Close
' End the program. (Check the file "file.ext" upon running to see the output.)
End
`
Differences from QB

- None

See also

- `Open`
- `Put (File I/O)`
- `Get (File I/O)`
- `FreeFile`