Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual Basic
 How to: Persist User Settings in Vi...

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual Basic Application Development
How to: Persist User Settings in Visual Basic

You can use the My.Settings.Save method to persist changes to the user settings.

Typically, applications are designed to persist the changes to the user settings when the application shuts down. This is because saving the settings can take, depending on several factors, several seconds.

For more information, see My.Settings Object.

NoteNote:

Although you can change and save the values of user-scope settings at run time, application-scope settings are read-only and cannot be changed programmatically. You can change application-scope settings when creating the application, through the Project Designer, or by editing the application's configuration file. For more information, see Managing Application Settings.

This example changes the value of the LastChanged user setting and saves that change by calling the My.Settings.Save method.

Visual Basic
Sub ChangeAndPersistSettings()
    My.Settings.LastChanged = Today
    My.Settings.Save()
End Sub

For this example to work, your application must have a LastChanged user setting, of type Date. For more information, see How to: Add or Remove Application Settings.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker