Export (0) Print
Expand All

Visual Basic Concepts

Visual Studio 6.0

Creating or Saving Application Settings

You can use the SaveSetting statement to save a new value for a registry key stored in your application's registry location. For example, you could add code to the Form_Unload event in the application's main form in order to preserve settings at shutdown, or in the Form_Unload event on an Options dialog box to update user preferences.

Use the following syntax for the SaveSetting statement:

SaveSetting appname, section, key, value

The following code saves new values for the Backup and LastEntry keys in the Startup section of the registry for an application named "RegCust." This code assumes that the variables strDate and intLastEntry contain the new values.

Private Sub Form_Unload(Cancel As Integer)
   SaveSetting "RegCust", "Startup", "Backup", strDate
   SaveSetting "RegCust", "Startup", "LastEntry", _
   intLastEntry
End Sub

If an entry for the application "RegCust" or any of these sections or keys don't exist in the Software/Microsoft section in the registry, this code will create it.

For More Information   See the "SaveSetting Statement."

Show:
© 2015 Microsoft