Understanding File IO

 < Day Day Up > 

Understanding File I/O

The term file I/O refers to file input and output functions, which is one way to manipulate the contents of a file. Although you might never use I/O functions, you might run into them in legacy applications that you must support.

The VBA I/O process is simple:

  • Use the VBA Open function to open a file.

  • Use the VBA Input function to retrieve a file's contents.

  • Use the VBA Write function to write to a file.

  • Use the VBA Print function to write a series of values to an open file.

Before you can use I/O to manipulate a file's contents, you need to know the file's handle. Within this context, a file handle is simply a number that uniquely identifies the open files to the operating system.

To open an I/O file, you need an unused file handle. Acquire this value using the FreeFile function in the form

 

 hFile = FreeFile 

where hFile is a Long Integer variable.

CAUTION

Chapter 23 is an introduction to using Windows API functions, which also uses file handles. You can't use the result of the VBA FreeFile function when working with an API.


     < Day Day Up > 


    Automating Microsoft Access with VBA
    Automating Microsoft Access with VBA
    ISBN: 0789732440
    EAN: 2147483647
    Year: 2003
    Pages: 186

    Similar book on Amazon

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