View contents of this chapter

The Write # Statement

Write # is another command that writes information to a sequential file. Write # and Print # vary only slightly. All data that Write # writes to a sequential file is comma delimited. Data written with Write # is usually read from a file with Input #.

Play Sound A comma delimited file is a file whose data is separated by commas.

The comma makes reading data less error prone, because subsequent Input # statements don't have to match the Write # statements exactly.

Write #filenumber, [outputlist]

The outputlist is the list of one or more comma-delimited numeric expressions or string expressions to write to a file. Consider the following code segment:

Private Sub Command1_Click()

    Dim intCounter As Integer
    Dim intFNum As Integer

    intFNum = FreeFile

    Open "C:\Write.txt"

    For intCounter = 1 To 5
        Write # intFNum, intCounter
    Next intCounter

    Close # intFNum
End Sub



© Universal Teacher Publications        INDEX Previous Screen Next Screen