SaveMySettingsOnExit Property

WindowsFormsApplicationBase.SaveMySettingsOnExit Property

Determines whether the application saves the user settings on exit.

Namespace:  Microsoft.VisualBasic.ApplicationServices
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public bool SaveMySettingsOnExit { get; set; }

Property Value

Type: System.Boolean
Boolean. True indicates that the application saves the user settings on exit. Otherwise, the settings are not implicitly saved.

The SaveMySettingsOnExit property allows the user to change how the application saves settings, at run time. You can explicitly save setting changes by using the Save method of the My.Settings object. For more information about changing and saving settings, see Managing Application Properties.

The changes to this property are not persisted when the application closes. To change the SaveMySettingsOnExit property permanently, you must change the setting in the Project Designer:

To change the setting in the Project Designer

  1. Have a project selected in Solution Explorer. Click Properties on the Project menu.

  2. Click the Application tab.

  3. Select Save My.Settings on Shutdown.

Availability by Project Type

Project type


Windows Forms Application


Class Library


Console Application


Windows Forms Control Library


Web Control Library


Windows Service


Web Site


This example has two parts.

  • The InitializeSaveMySettingsOnExit subroutine, which initializes the checked state of a CheckBox control to the current value of the SaveMySettingsOnExit property.

  • The SaveMySettingsOnExit_CheckedChanged subroutine, which handles changes to a CheckBox control to update the My.Application.SaveMySettingsOnExit property.

Private Sub InitializeSaveMySettingsOnExit()
    SaveMySettingsOnExit.Checked = 
End Sub
Private Sub SaveMySettingsOnExit_CheckedChanged( 
    ByVal sender As System.Object, 
    ByVal e As System.EventArgs 
) Handles SaveMySettingsOnExit.CheckedChanged
    My.Application.SaveMySettingsOnExit = 
End Sub

For this example to work, your application must have a CheckBox control named SaveMySettingsOnExit.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

© 2016 Microsoft