Visual Basic Language Reference  

FileGet Function

Reads data from an open disk file into a variable.

Public Overloads Sub FileGet( _
   ByVal FileNumber As Integer, _
   ByRef Value As Object, _
   Optional RecordNumber As Integer = -1 _
)

-or-

Public Overloads Sub FileGet( _
   ByVal FileNumber As Integer, _
   ByRef Value As Short, _
   Optional RecordNumber As Integer = -1 _
)

-or-

Public Overloads Sub FileGet( _
   ByVal FileNumber As Integer, _
   ByRef Value As Integer, _
   Optional RecordNumber As Integer = -1 _
)

-or-

Public Overloads Sub FileGet( _
   ByVal FileNumber As Integer, _
   ByRef Value As Single, _
   Optional RecordNumber As Integer = -1 _
)

-or-

Public Overloads Sub FileGet( _
   ByVal FileNumber As Integer, _
   ByRef Value As Double, _
   Optional RecordNumber As Integer = -1 _
)

-or-

Public Overloads Sub FileGet( _
   ByVal FileNumber As Integer, _
   ByRef Value As Decimal, _
   Optional RecordNumber As Integer = -1 _
)

-or-

Public Overloads Sub FileGet( _
   ByVal FileNumber As Integer, _
   ByRef Value As Byte, _
   Optional RecordNumber As Integer = -1 _
)

-or-

Public Overloads Sub FileGet( _
   ByVal FileNumber As Integer, _
   ByRef Value As Boolean, _
   Optional RecordNumber As Integer = -1 _
)

-or-

Public Overloads Sub FileGet( _
   ByVal FileNumber As Integer, _
   ByRef Value As Date, _
   Optional RecordNumber As Integer = -1 _
)

-or-

Public Overloads Sub FileGet( _
   ByVal FileNumber As Integer, _
   ByRef Value As System.Array, _
   Optional RecordNumber As Integer = -1, _
   Optional ArrayIsDynamic as Boolean = False _
)

-or-

Public Overloads Sub FileGet(
   ByVal FileNumber As Integer, _
   ByRef Value As String, _
   Optional RecordNumber As Integer = -1, _
   Optional StringIsFixedLength as Boolean = False _
)

Parameters

FileNumber
Required. Any valid file number.
Value
Required. Valid variable name into which data is read.
RecordNumber
Optional. Record number (Random mode files) or byte number (Binary mode files) at which reading begins.
ArrayIsDynamic
Optional. Applies only when writing an array. Specifies whether the array is to be treated as dynamic and so whether to write an array descriptor describing the size and bounds of the array.
StringIsFixedLength
Optional. Applies only when writing a string. Specifies whether to write a two-byte descriptor for the string describing the length. The default is False.

Exceptions/Errors

Exception type Error number Condition
ArgumentException 63 RecordNumber < 1 and not equal to -1.
IOException 52 FileNumber does not exist.
IOException 54 File mode is invalid.

Remarks

FileGet is only valid in Random and Binary mode.

Data read with FileGet is usually written to a file with FilePut.

The first record or byte in a file is at position 1, the second record or byte at position 2, and so on. If you omit RecordNumber, the next record or byte following the last FileGet or FilePut function (or pointed to by the last Seek function) is read.

For files opened in Random mode, the following rules apply:

For files opened in Binary mode, all of the Random mode rules apply, except:

See Also

FileOpen Function | FilePut Function | Seek Function | FileGetObject Function