Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 36,044 times

Contents

Related Categories

Registry - Saving Settings

Saving Settings

To utilise the registry, VB provides a simple function called SaveSetting. The SaveSetting function uses the following syntax:

SaveSetting AppName, Section, Key, Value, [Default]

Where AppName is the name of your application, Section is the next folder up and Key is the item your value is stored in.

For example, the following code will save the contents of TextBox1 in the registry. You do not need to know this, but the full path would be (if using Win 98)

HKEY_USERSCurrentUserSoftwareVB and VBA Program SettingsAppNameSectionKey

You can take a look at this by clicking Start | Run... and type C:Windows egedit.exe . Then look in the path above. However, if you want to change anything, you should back up the registry first!

The following code saves the value of TextBox1.Text to the registry:

' Save the value in Text Box 1
SaveSetting App.Title, "Default Settings", "Font", TextBox1.Text

NOTE: this value will be stored in the current users 'section' in the registery. Other users can change this value without affecting other users settings

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.

Comments

  • this seems to work for me

    Posted by crezzy_man on 10 Aug 2003

    this will create a key under hkey_local_machine\software
    named MyFirstKey
    and under that key it will set the default subkey to equal c:\progran files\my
    and create another key called Example with t...

  • Posted by HyperHacker on 28 May 2003

    This isn't quite the best place for your question. Anyway, I would do it like this:
    On keydown, set movement to Up.
    On keyup, set movement to None.
    Then when you press the key, the player moves up,...

  • Pause after KeyPress

    Posted by DalePeach on 23 Oct 2002

    How do you stope the pause after a keypress? For Example, if you have a game where the arrow key's are used and the player is walking by holding down the arrow key, the player will walk a step, pause ...

  • Posted by James Crowley on 13 Sep 2002

    You need to use Windows API (see http://www.developerfusion.com/show/1857/)

  • GetSettings only USER registry???

    Posted by DalePeach on 13 Sep 2002

    Yes I tried this too, but you can't access anything outside the VB Registry and the User Restry. How do you access things in the Root or under HKEY_LOCAL_MACHINE\SOFTWARE

    ? ? ?