View contents of this chapter

Working with Files

Most programs today use files. Even if a program doesn't use files, the program itself is a file that executes when a user runs the program. Let's take a look at some of the basic file I/O commands.

The Open Statement

The Open command opens a file in Visual Basic 6. The kind of file access you achieve with the Open depends on the arguments you use in the Open statement.

Open pathname For mode [Access access] [lock] As [#]filenumber [Len=reclength]

A simple call to Open with only the required parameters might look like this:

Open "Hello.txt" As #1

The above statement opens a file named Hello.txt as file number 1. To reference this file for I/O, you reference the file number.

Play Sound By default, when you omit the For Mode portion, the file is opened in Random mode.



© Universal Teacher Publications        INDEX Previous Screen Next Screen