Visual Basic 2008 Programming: Business Applications with a Design Perspective
Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9
Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Appendix A Appendix B Appendix C Home
Loading
Last change: February 13 2016 18:48:19.

 Chapter in PDF

Table of Contents

Chapter 14 Beyond the Core
Last change: February 13 2016 18:47:53.
<<PreviousNext>>

14.1 Persisting Application Settings

Imagine that you encounter a situation in which you would like your program to have some VB control properties set to certain values. However, you might be hesitant to hard-code the values because you want to allow your user to choose these values or because the computer in which your program will run may be different from the computer you use to develop the program and the property values that are available in one computer may not be available in the other.

One possible solution to this problem is to create a special file to keep these special settings, but this solution has several drawbacks. The code to handle the file can take many lines. Determining the proper file path can also be an issue. Finally, you will need to secure the file from the user’s accidental alteration or destruction.

Two alternatives are available. A traditional technique is to use the Windows registry, which is a database that the Windows operating system maintains to support the system’s and applications’ operations. The other alternative is to use the My.Settings object available in the newer VB editions (2005 and newer). The following discussion illustrates how to apply these two techniques.

Last change: February 13 2016 18:47:53.
  1. 14.1 Persisting Application Settings
    1. Using the Windows Registry for application settings
    2. Using the My.Settings Object
    3. Additional Remarks
    4. <<PreviousNext>>