Resources and Settings Sample

To get samples and instructions for installing them, see the following:

  • Click Samples on the Visual Studio Help menu.

    For more information, see Locating Sample Files.

  • The most recent versions and the complete list of samples are available on the Visual Studio 2008 Samples Web site.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied to a folder under \Program Files\Visual Studio 9\Samples\. For Visual Studio Express Editions, all samples are located on the Internet.

To run this sample

  • Press F5.

    Each time that you run the application, a different background is displayed.

Demonstrates

A setting is used to keep track of the number of times the application has been run. Each time the application runs, the setting is examined, and one of several available desktop images is selected based on that number. Consequently, every time that you run the application, you see a new background.

The code resides in the SetBackground method of Form1 and in the application startup and shutdown events, which are handled in My Project\MyEvents.vb. To view this file, double-click My Project in Solution Explorer. On the Application panel of the Project Designer, click the View Application Events button.

Settings are created and modified on the Settings tab of the Project Designer. There are two types of settings: application and user. Application settings are those with values that are common to all instances of the application. User settings are created and modified for each user. In this sample, the setting that persists the number of times an installation of the application has been executed is a user setting.