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.


语法:

Write Statement diagram


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

参数:

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」语句,其结尾用一个行结束符号输出。

根据区域设置,转换带小数分隔符的数值。

示例:


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

请支持我们!