O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 appname or section subkeys are not found in the registry, they are automatically created.

  • The function writes a value to a subkey of the KEY_CURRENT_USER\Software\ VB and VBA Program Settings key of the registry.

  • section need not be an immediate subkey of appname; instead, section can be a fully qualified path to a nested subkey, with each subkey separated from its parent by a backslash. For example, a value of Settings\Coordinates for the section argument indicates that the value is to be retrieved from HKEY_CURRENT_USER\Software\VB and VBA Program Settings\appname\Settings\Coordinates.

  • Visual Basic writes setting to the registry as a string (REG_SZ) value. If setting is 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required