VB6 Lock statement syntax: - Lock [#]filenumber[, recordrange] Controls access to all or part of an open file. The Lock statement syntax has these parts:
| Part | Description |
|---|---|
| filenumber | Required. Any valid file number. |
| recordrange | Optional. Range of records to lock. Can be: record, start To end, or omitted for entire file. |
Remarks
- Lock and Unlock are used in environments where multiple processes might need access to the same file.
- Lock and Unlock statements are always used in pairs.
- For Binary, Input, or Output mode, Lock always locks the entire file regardless of recordrange.
- For Random mode, Lock locks the specified record or range of records.
Examples
Lock #1
Lock #1, 5
Lock #1, 10 To 20