Open Instruction
Syntax
Open Name$ For mode [Access access] [lock] As _ [#]StreamNum [Len = RecordLen]
Group
Description
Open file Name$ for mode as StreamNum.
Reading Unicode Files
To read a Unicode (UTF-16 or UTF-8) file, just open using Input mode. All the input is converted automatically.
Writing Unicode Files
To write a Unicode (UTF-16 or UTF-8) file, open using Output or Append mode and write the appropriate Byte Order Mark (BOM). All the printed output is converted automatically.
To create a Unicode (UTF-16) text file use:
Open FileName$ For Output As #fn Print #fn, vbUTF16BOM; ' first char is the UTF-16 Byte Order Mark ... ' everything automatically converted to UTF-16 Close #fn
To create a Unicode (UTF-8) text file use:
Open FileName$ For Output As #fn Print #fn, vbUTF8BOM; ' first three chars are the UTF-8 Byte Order Mark ... ' everything automatically converted to UTF-8 Close #fn
Pocket PC
Access and lock ignored.
Parameters
Parameters | Description |
---|---|
Name$ | This string value is the path and name of the file. A path relative to the current directory can be used. |
mode | May be Input, Output, Append, Binary or Random. |
access | May be Read, Write or Read Write. (Only allowed for Binary and Random modes.) |
lock | May be Shared, Lock Read, Lock Write or Lock Read Write. |
StreamNum | Streams 1 through 255 are private to each macro. Streams 256 through 511 are shared by all macros. |
RecordLen | This numeric value is the record length for Random mode files. Other file modes ignore this value. |
Example
Sub Main Open "XXX" For Output As #1 Print #1, "1,2,""Hello""" Close #1 End Sub
See also