Name
FileGet, FileGetObject Procedures
Class
Microsoft.VisualBasic.FileSystem
Syntax
FileGet(FileNumber, Value, RecordNumber
) FileGetObject(FileNumber, Value, RecordNumber
)
-
FileNumber
(required; Integer) Any valid file number
-
Value
(required; any (see the first two items in Section ) Variable in which to place file contents
-
RecordNumber
(optional; Integer) The location at which reading begins
Description
Copies data from a file on disk into a variable
Rules at a Glance
For the FileGet procedure, the variable can have one of the following data types:
Array Boolean Byte Char Date Decimal Double Integer Long Short Single String For the FileGetObject procedure, the variable must be of type Object.
For files opened in Random mode,
RecordNumber
refers to the record number in the file.For files opened in Binary mode,
RecordNumber
refers to the byte number within the file.The number of bytes read by the FileGet procedure is governed by the data type of
Value
. The following is the number of bytes read by each data type:
Data type |
Bytes read |
---|---|
Boolean |
2 |
Byte |
1 |
Char |
1 |
Date |
8 |
Decimal |
8 |
Double |
16 |
Integer |
4 |
Long |
8 |
Short |
2 |
Single |
8 |
String |
Len( |
Note that the number of bytes read by a String variable depends on the length of the string. Hence, a string must be initialized to the desired size before calling the FileGet procedure.
The position of the first record or byte within a file is always 1.
When a record or a number of bytes is read from a file using FileGet, the file pointer automatically ...
Get VB.NET Language in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.