Home > How-To Library > Registry

Save and retrieve registry settings.

**************************************************************** * © 2007 CodeItBetter http://www.codeitbetter.com * * This notice MUST stay intact for legal use * ****************************************************************
'Variant to hold 2-dimensional array returned by GetSetting. Dim MySettings As Variant ' Unused in the example. Not sure why it's there. ' Place some settings in the registry. ' Saves the Top and Left position of a form, so that it starts in the right place SaveSetting "MyApp", "Startup", "Top", 75 ' app name, key name, Value SaveSetting "MyApp", "Startup", "Left", 50 ' prints out what you''ve written ' in GetSettings, if a value isn't found, you can specify a default. ' in this case, left isn't found, so 25 is the default Debug.Print GetSetting(appname:="MyApp", section:="Startup", Key:="Left", Default:="25") ' and this deletes both settings, in case you want to re-write them DeleteSetting "MyApp", "Startup"

If you would like to submit your code here please us. Do not forget to mention your name. We are always thankful to each and everyone of you who submitted their code here.