Name
SaveSetting Procedure
Class
Microsoft.VisualBasic.Interaction
Syntax
SaveSetting(appname,section,key,setting)
-
appname(required; String) The name of the application
-
section(required; String) The name of the registry key
-
key(required; String) The name of the value entry whose value is to be saved
-
setting(required; String or numeric) The value to save
Description
Creates or saves an entry for a VB application in the Windows registry
Rules at a Glance
If either the
appnameorsectionsubkeys are not found in the registry, they are automatically created.The function writes a value to a subkey of the
KEY_CURRENT_USER\Software\ VBand VBA ProgramSettingskey of the registry.sectionneed not be an immediate subkey ofappname; instead,sectioncan be a fully qualified path to a nested subkey, with each subkey separated from its parent by a backslash. For example, a value ofSettings\Coordinatesfor thesectionargument indicates that the value is to be retrieved fromHKEY_CURRENT_USER\Software\VBand VBA ProgramSettings\appname\Settings\Coordinates.Visual Basic writes
settingto the registry as a string (REG_SZ) value. Ifsettingis not a string, VB attempts to coerce it into a string in order to write it.If the setting cannot be saved, a runtime error will be generated.
Programming Tips and Gotchas
The built-in registry-manipulation functions allow you to create professional 32-bit applications that use the registry for holding application-specific data, in the same way that .INI ...