Unlock Procedure


Unlock Procedure

Class

Microsoft.VisualBasic.FileSystem

Syntax

     Unlock(fileNumber[, record]) 

or:

     Unlock(fileNumber[, fromRecord, toRecord]) 


fileNumber (required; Integer)

Any valid file number of a file opened with FileOpen


record (required; Long)

The 1-based record or byte number at which to commence lock removal


fromRecord (required; Long)

The first 1-based record or byte number to unlock


toRecord (required; Long)

The last 1-based record or byte number to unlock

Description

The Unlock procedure removes record, section, or file locks previously set using the Lock procedure. Locks are used in situations where multiple programs or more than one instance of the same program may need read-and-write access to the same data file.

Usage at a Glance

  • If only the fileNumber argument is included, the entire file is unlocked.

  • record is interpreted as a record number in Random files and as a byte number in Binary files.

  • The Unlock procedure unlocks an entire file opened in Input or Output (sequential) mode, regardless of any record number arguments.

  • The matching Lock procedure must include the same arguments.

  • All file locks should be removed with the Unlock procedure before either closing a file or ending the application; otherwise, you can leave a file in an unstable state. Where appropriate, error-handling code must correctly unlock any locks that are no longer necessary.

Version Differences

  • In VB 6, the fromRecord argument can be left blank to unlock all records up to toRecord. This syntax is not supported in .NET.

  • In the VB 6 Unlock statement, you can separate the fromRecord and toRecord arguments with the To keyword. In the .NET Unlock procedure, this syntax is not supported.

  • In Visual Basic 2005, the My.Computer.FileSystem object provides more robust access to file management features.

See Also

Lock Procedure




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net