Visual Basic Concepts
You can use the GetSetting and GetAllSettings functions to retrieve registry values stored in your application's registry location. For example, your application can retrieve registry settings to recreate its condition at the time it was closed.
To retrieve a single registry setting, use the following syntax for the GetSetting function:
GetSetting(appname, section, key[, default])
The following code retrieves the value of the LastEntry key in the "RegCust" application's Startup section, and displays the value in the Immediate window.
Private Sub Form_Load()
Dim intLastEntry As Integer
intLastEntry = GetSetting("RegCust", "Startup", _
"LastEntry", "0")
Debug.Print intLastEntry
End Sub
Note that you can use the optional parameter, default, to set the value returned by Visual Basic when there is no value listed in the registry for the specified key.
To retrieve a list of registry keys and their values, use the following syntax for the GetAllSettings function:
GetAllSettings(appname, section)
The following code retrieves a two-column list of registry keys and their values in the "RegCust" application's Startup section, and displays the results in the Immediate window.
Private Sub Form_Load()
Dim avntSettings As Variant
Dim intX As Integer
avntSettings = GetAllSettings("RegCust", "Startup")
For intX = 0 To UBound(avntSettings, 1)
Debug.Print avntSettings(intX, 0), _
avntSettings(intX, 1)
Next intX
End Sub
For More Information See "GetSetting Function" and "GetAllSettings Function."