Databases Reference
In-Depth Information
FIGURE 2.15 The SaveRegSettings subroutine creates these registry entries (shown with Path key values).
When the GUI is loaded into memory, the settings stored in the Windows Registry using the
above routines must be read and assigned back to the objects that reside in the GUI. However,
there is one important factor to think about here, and it is literally a “which came first, the chicken
or the egg” scenario. Consider this: if the application is installed on a machine and has never been
run, then there are no settings in the Windows Registry for the program to read. Trying to read
keys that do not exist from the Windows Registry will result in empty strings being returned. Setting
the property of an object to an empty string will result in an error.
What makes the most sense is to create a function in which the property to be set is passed by
Reference, and if the key exists for that object, set the property for that object within the function.
Because the property is passed by reference, it should propagate back to the original object on the
form. Unfortunately, it will not . Thus, a function such as the one shown in the following text will not
work correctly.
Function SetPropFromRegKey(ByRef Property, ByVal appname$,
ByVal section$, ByVal key$) As Variant
'This Function will not work. A Bug in VBA prevents Properties of
'Objects from being set when being passed by reference
FIGURE 2.16 The Checkbox key values stored in the Windows Registry.
Search WWH ::




Custom Search