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!