• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 13. Exploiting the Power of Clas... > Practical Examples: Class Modules

Practical Examples: Class Modules

To best understand how to benefit from the use of Class modules, it is beneficial to see them in action. This chapter covers three examples. The first shows the use of a file information class. Each instance of the class is used to house information about a particular file. The second illustrates how the use of a customer class facilitates the process of dealing with customer data. The third is a system information class. It retrieves and then provides information about the computer system. An additional example of the use of Class modules is found in Chapter 16. It shows how a custom error class facilitates the process of implementing error handling within your application.

The FileInformation Class

It is a common application requirement to be able to extract the drive, path, or short filename from a complete filename. Although you can obtain these pieces of information using a Standard Code module and functions, placing the functions in a Class module makes them easier to work with. The FileInformation class contained in the Chap13Ex sample database contains four properties: FullFileName, Drive, Path, and Name. The user of the class sets the FullFileName property. It contains the complete filename and path of the file whose parts the user wishes to extract. The Drive, Path, and Name properties of the class contain the drive, path, and name of the file specified in the FullFileName property. Listing 13.1 shows the Property Let and Property Get procedures, as well as the Private variables associated with these properties.



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint