Write# Statement

Writes data to a sequential text file with delimiting characters.

tip

Use Print# statement to print data to a sequential text file. Use Put# statement to write data to a binary or a random file.


Syntax:

Write Statement diagram


Write [#fileNum] {,|;} expression [, …]

Parameters:

fileNum: Any numeric expression that contains the file number that was set by the Open statement for the respective file.

expression list: Variables or expressions that you want to enter in a file, separated by commas.

如果省略了表示式清單,Write 陳述式會附加至檔案的空行。

若要將表示式清單加入新檔案或現有檔案中,必須以 Output 模式或 Append 模式開啟檔案。

您所寫入的字串前後帶有引號,並以逗號分隔。表示式清單中不需要輸入分隔符。

每個 Write 陳述式會輸出行結束符號做為最後的輸入。

含小數點分隔符的數字會根據語言環境設定進行轉換。

Example:


Sub ExampleWrite
    Dim iCount As Integer
    Dim sValue As String
    iCount = Freefile
    Open "C:\data.txt" For Output As iCount
    sValue = "Hamburg"
    Write #iCount,sValue,200
    sValue = "New York"
    Write #iCount,sValue,300
    sValue = "Miami"
    Write #iCount,sValue,450
    Close #iCount
End Sub

Please support us!