Search notes:

VBA statement: write#

write# is designed to generate machine-readable output that are later consumed with input#.
Therefore, strings being written with write# are enclosed in apostrophes. In order for VBA not to write the apostrophes, print# should be used.
write# also automatically adds a line break.
option explicit

sub main() ' {

    dim fileName as string
    fileName = environ$("temp") & "\VBA-print-test.txt"

    dim f as integer
    f = freeFile()

    open fileName for output as #f

    write# f, "Line one"
    write# f, "Line two"
    write# f, "Line three"

    close f

    debug.print("Check " & fileName)

end sub ' }
Github repository about-VBA, path: /language/statements/write/test.bas
The written file then looks as follows:
"Line one"
"Line two"
"Line three"

See also

VBA statements

Index