UNLOCK |
UNLOCK ([#] filenumber [,recordrange]) |
Controls access to a file. |
filenumber | The number of the file (Integer). |
recordrange | (Optional) The range of records (or bytes) to unlock (Long). |
REMARKS |
* Removes locking that prevents another process from accessing all or part of the open file that corresponds to the filenumber. * This is closely related to the LOCK statement. * The equivalent .NET statement is Microsoft.VisualBasic.FileSystem.Unlock * For the Microsoft documentation refer to learn.microsoft.com |
Dim MyRecord As udtRecord
Dim RecordNumber As Integer
'Open "C:\Temp\MyText.txt" For Output As #1 'Close #1 '
'Open "C:\Temp\MyText.txt" For Binary As #1 'RecordNumber = 1 'MyRecord.ID = "001"
'MyRecord.Name = "Name1"
'Put #1, , MyRecord
'MyRecord.ID = "002"
'MyRecord.Name = "Name2"
'Put #1, , MyRecord
'Close #1
Open "C:\Temp\MyText.txt" For Binary Shared As #1 Len = VBA.Len(MyRecord)
RecordNumber = 1 ' Define record number.
Lock #1, RecordNumber ' Lock record.
Get #1, RecordNumber, MyRecord ' Read record.
MyRecord.ID = 111 ' Modify record.
MyRecord.Name = "New Name1"
VBA>Put #1, RecordNumber, MyRecord ' Write modified record.
Unlock #1, RecordNumber ' Unlock current record.
Close #1 ' Close file.
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top