Siebel VB Language Reference > Methods Reference for Siebel VB > File Control Methods >

Close File Method


The Close File method closes a file and stops any input or output operations to this file. It does not return a value. When it runs, Siebel VB writes the final output buffer to the operating system buffer for this file. It frees the buffer space that is associated with the closed file. You can use the Close All Files method to cause the operating system to move the data in the buffers to disk. For more information, see Close All Files Method.

Format

Close [[#]filenumber [, [#]filenumber ... ]]

The following table describes the arguments that you can use with this method.

Argument
Description

filenumber

The file number that the Open statement uses to open the file. It identifies the file to close.

The value in the filenumber argument is the number that the Open statement assigns to the file. A pound sign (#) can precede this argument. If you do not include this argument, then the Close statement closes every open file.

When a Close statement runs, the association of a file with filenumber is ended, and Siebel VB can reopen this file with the same or a different file number.

Example

The following example opens a file for random access, gets the contents of one variable, and then closes the file. The CreateFile subroutine creates the c:\temp001 file that the main subroutine uses:

(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

Siebel VB Language Reference Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.