LibreOffice 7.1 Help
ΠΡΠΊΡΡΠ²Π°Π΅Ρ ΠΊΠ°Π½Π°Π» Π΄Π°Π½Π½ΡΡ .
Open pathname For mode [Access io] [locking] As [#]filenum [Len=recLen]
pathname: Path and name of the file to open. If you try to read a file that does not exist (Access = Read), an error message appears. If you try to write to a file that does not exist (Access = Write), a new file is created.
mode: Keyword that specifies the file mode. Valid values: Append (append to sequential file), Binary (data can be accessed by bytes using Get and Put), Input (opens data channel for reading), Output (opens data channel for writing), and Random (edits relative files).
io: Keyword that defines the access type. Valid values: Read (read-only), Write (write-only), Read Write (both).
locking: Keyword that defines the security status of a file after opening. Valid values: Shared (file may be opened by other applications), Lock Read (file is protected against reading), Lock Write (file is protected against writing), Lock Read Write (denies file access).
filenum: Any integer expression from 0 to 511 to indicate the number of a free data channel. You can then pass commands through the data channel to access the file. The file number must be determined by the FreeFile function immediately before the Open statement.
recLen: For Random access files, set the length of the records.
Π€Π°ΠΉΠ» Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±ΡΡΡ ΠΎΡΠΊΡΡΡ ΠΈΠ½ΡΡΡΡΠΊΡΠΈΠ΅ΠΉ Open, ΠΏΠ΅ΡΠ΅Π΄ ΡΠ΅ΠΌ ΠΊΠ°ΠΊ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ΅ ΡΡΠΎΠ³ΠΎ ΡΠ°ΠΉΠ»Π° ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΎ. ΠΡΠΈ ΠΏΠΎΠΏΡΡΠΊΠ΅ ΠΎΡΠΊΡΡΡΡ ΡΠ°ΠΉΠ», ΠΊΠΎΡΠΎΡΡΠΉ ΡΠΆΠ΅ ΠΎΡΠΊΡΡΡ, ΠΏΠΎΡΠ²ΠΈΡΡΡ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ ΠΎΠ± ΠΎΡΠΈΠ±ΠΊΠ΅.
Sub ExampleWorkWithAFile
Dim iNumber As Integer
Dim sLine As String
Dim aFile As String
Dim sMsg As String
aFile = "c:\data.txt"
iNumber = Freefile
Open aFile For Output As #iNumber
Print #iNumber, "ΠΡΠΎ ΡΡΡΠΎΠΊΠ° ΡΠ΅ΠΊΡΡΠ°"
Print #iNumber, "ΠΡΠΎ Π΅ΡΠ΅ ΠΎΠ΄Π½Π° ΡΡΡΠΎΠΊΠ° ΡΠ΅ΠΊΡΡΠ°"
Close #iNumber
iNumber = Freefile
Open aFile For Input As iNumber
While Not eof(iNumber)
Line Input #iNumber, sLine
If sLine <>"" Then
sMsg = sMsg & sLine & chr(13)
End If
Wend
Close #iNumber
MsgBox sMsg
End Sub