Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95


View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?

 

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

 

 

 

Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Class: ProgramSettings in Category Windows : Registry from Total Visual SourceBook

Simplified registry access routines used for saving program settings in VB6 and VBA with 32 and 64 bit Windows API calls.

This class is designed to store information about a single program to a single location in the Windows registry. Typically it is used to store program-specific run-time settings or switches such as form locations, or most-recently-used menu items.

Procedure List

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the CProgramSettings class
MainBranch Property Get the MainBranch property (defaults to "SOFTWARE").
Program Property Get the name of the current program for which settings are saved.
RegBase Property Get the "base" registry entry (for example, each company's products might use the company name as the registry base).
RootKey Property Get the RootKey used for the registry entries.
Section Property Get the section of the registry to use to store the value in, within the RegBase and Product section (default value is "Settings"). You can specify a subkey by using a backslash as part of the value, e.g. "Settings\Forms\Positions"
Class_Initialize Initialize Set initial values to defaults which may be overridden with property settings.
ReadEntry Method Read a string value from the location in the registry specified by the class properties (Hive, MainBranch, RegBase, and Program).
WriteEntry Method Write a string entry into the registry at the location specified by the class properties (Hive, MainBranch, RegBase, and Program).
GetKeyValue Private Retrieve the specified key value.
SetKeyValue Private Set a registry value. Will create key if it doesn't exist.

Example Code for Using Class: ProgramSettings

' Example of CProgramSettings
'
' To try this example, do the following:
' 1. Create a new form
' 2. Create a command button 'cmdSetTime'
' 3. Create a command button 'cmdReadTime'
' 4. Paste all the code from this example to the new form's module.
' 5. Run the form

Private mProgramSettings As CProgramSettings

Private Sub cmdSetTime_Click()

  If mProgramSettings Is Nothing Then
    CreateProgramSettings
  End If

  ' Write an entry to the registry
  mProgramSettings.WriteEntry "Time", "Current Time: " & Now
End Sub

Private Sub cmdReadTime_Click()
  Dim strEntry As String

  If mProgramSettings Is Nothing Then
    CreateProgramSettings
  End If

  ' Read an entry from the registry
  strEntry = mProgramSettings.ReadEntry("Time", "Time not entered yet")
  Debug.Print strEntry

End Sub

Private Sub CreateProgramSettings()
  Set mProgramSettings = New CProgramSettings

  ' Set property settings to determine where the settings will be saved.
  ' In this example, the settings to into the same location used by the VBA/VB6 SaveSetting/GetSettings routines.
  ' This could be your company name, or the name of another known company such as "Microsoft"

  With mProgramSettings
    .RootKey = psrHKEY_LOCAL_MACHINE
    .MainBranch = "SOFTWARE"
    .RegBase = "FMS"
    .Program = "Test CProgramSettings"
    .Section = "Settings"
  End With

End Sub

Private Sub Form_Load()
  Me.cmdReadTime.Caption = "ReadTime"
  Me.cmdSetTime.Caption = "SetTime"
End Sub

Microsoft Access Module LibraryOverview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources