Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Use registry to save program settings


Sub Settings(Task As String )
'call this with "Get" during form load
'call this with "Save" during form unload
If Task = "Get" Then
   'run this during form load event
   'these are sample values - get/save whatever you program needs
    Me .Left = GetSetting(App.Title, "Settings" , "MainLeft" , "1200" )
    Me .Top = GetSetting(App.Title, "Settings" , "MainTop" , "1200" )
    Me .Width = GetSetting(App.Title, "Settings" , "MainWidth" , "8085" )
    Me .Height = GetSetting(App.Title, "Settings" , "MainHeight" , "3630" )
   mnuIgnoreCase.Checked = GetSetting(App.Title, "Settings" , "IgnoreCase" , vbChecked)
   mnuHighlight.Checked = GetSetting(App.Title, "Settings" , "HighLight" , vbChecked)
Else
    'run this during form unload event
    'these are sample values - get/save whatever you program needs
   SaveSetting App.Title, "Settings" , "MainLeft" , frmMain.Left
   SaveSetting App.Title, "Settings" , "MainTop" , frmMain.Top
   SaveSetting App.Title, "Settings" , "MainWidth" , frmMain.Width
   SaveSetting App.Title, "Settings" , "MainHeight" , frmMain.Height
   SaveSetting App.Title, "Settings" , "IgnoreCase" , mnuIgnoreCase.Checked
   SaveSetting App.Title, "Settings" , "HighLight" , mnuHighlight.Checked
End If
End Sub