Siebel VB Language Reference > VB Language Reference >
Close Statement
This standard VB statement closes a file, concluding input/output to that file. Syntax
Close [[#]filenumber [, [#]filenumber ... ]]
|
|
filenumber |
The file number used in the Open statement to open the file, identifying the file to close |
Returns
Not applicable Usage
Filenumber is the number assigned to the file in the Open statement and can be preceded by a pound sign (#). If this argument is omitted, every open file is closed. When a Close statement is executed, the association of a file with filenumber is ended, and the file can be reopened with the same or a different file number. When the Close statement is used, the final output buffer is written to the operating system buffer for that file. Close frees the buffer space associated with the closed file. Use the Reset statement so that the operating system flushes its buffers to disk. Example
This example opens a file for random access, gets the contents of one variable, and closes the file again. The subprogram, CreateFile , creates the file c:\temp001 used by the main subprogram. (general) (declarations) Option Explicit Declare Sub CreateFile
Sub CreateFile Rem Put the numbers 1-10 into a file Dim x as Integer Open "c:\temp001" for Output as #1 For x = 1 to 10 Write #1, x Next x Close #1 Reset End Sub
Sub Button1_Click Dim acctno as String * 3 Dim recno as Long Dim msgtext as String Call CreateFile recno = 1 newline = Chr(10) Open "c:\temp001" For Random As #1 Len = 3 msgtext = "The account numbers are:" & newline & newline Do Until recno = 11 Get #1,recno,acctno msgtext = msgtext & acctno recno = recno + 1 Loop Close #1 Reset Kill "c:\temp001" End Sub
Related Topics
Open Statement Reset Statement Stop Statement
|