Siebel VB Language Reference > VB Language Reference >

Write Statement


This standard VB statement writes data to an open sequential file.

Syntax

Write [#]filenumber[, expressionList]

Argument
Description

filenumber

The file number used in the Open statement to open the file

expressionList

One or more values to write to the file

Returns

Not applicable

Usage

The file must be opened in output or append mode. If expressionList is omitted, the Write statement writes a blank line to the file. For more information, read Input Statement.

NOTE:  The Write statement results in quotes around the string that is written to the file.

Example

This example writes a variable to a disk file based on a comparison of its last saved time and the current time.

Sub Button_Click
   Dim tempfile
   Dim filetime, curtime
   Dim msgtext
   Dim acctno(100) as Single
   Dim x, I
   tempfile = "C:\TEMP001"
   Open tempfile For Output As #1
   filetime = FileDateTime(tempfile)
   x = 1
   I = 1
   acctno(x) = 0
   Do
      curtime = Time
      acctno(x) = 88




      If acctno(x) = 99 then
         If x = 1 then Exit Sub
         For I = 1 to x-1
            Write #1, acctno(I)
         Next I
         Exit Do
      ElseIf (Minute(filetime) + 2)< = Minute(curtime) then
         For I = I to x-1
            Write #1, acctno(I)
         Next I
      End If
      x = x + 1
   Loop
   Close #1
   x = 1
   msgtext = "Contents of C:\TEMP001 is:" & Chr(10)
   Open tempfile for Input as #1
   Do While Eof(1) <> -1
      Input #1, acctno(x)
      msgtext = msgtext & Chr(10) & acctno(x)
      x = x + 1
   Loop
   Close #1
      Kill "C:\TEMP001"
End Sub

See Also

Close Statement
Open Statement
Print Statement
Put Statement

Siebel VB Language Reference