VISUAL BASIC METHODS
Visual Basic provides a number of commands for manipulating the filesystem. These commands are relatively flexible and easy to understand. Most of them have been around since the early days of Visual Basic, so many long-time Visual Basic developers prefer to use them rather than the newer .NET Framework methods.
One disadvantage to these methods is that they do not natively allow you to read and write nonstandard data types. They can handle string, date, integer, long, single, double, and decimal data. They can also handle structures and arrays of those types. They cannot, however, handle classes themselves. You can use XML serialization to convert a class object into a string and then use these methods to read and write the result, but that requires an extra step with some added complexity.
The section “File System Methods” later in this chapter describes the native filesystem methods of Visual Basic. The sections “Sequential-File Access,”“Random-File Access,” and “Binary-File Access” later in this chapter describe specific issues for working with sequential, random, and binary files.
File Methods
The following table describes the methods Visual Basic provides for working with files:
| METHOD | PURPOSE |
| EOF | Returns True if a file open for reading is at the end of file. (EOF stands for End Of File.) |
| FileClose | Closes an open file. |
| FileGet | Reads data from a file opened in Random or Binary mode into a variable. |
| FileGetObject | Reads data as an object from ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access