Visual Basic Developer
 
HomeArticlesSamplesAbout Us

Reading from the Registry

In a previous article I showed you how to save settings in the registry. Now I'm going to show you how to get them back out again.

The basic syntax is:

GetSetting("MyApp", "Category", "InfoName", "DefaultValue")

So lets look at the article on saving information in the registry. I used this example to save a username:

SaveSetting "My App", "Users", "Username", Name1.Text

Now, we're going to pull this information out and and display the username in the title of the application. This code goes in the Load sub in your application. The name of the form we are working on is irrelevant because I used the term "me" which refers to the current form the code is on.

Me.Caption = "Weclcome " + GetSetting("MyApp", "Users", "Username", "To MyApp")

If no value is found in the registery, the default value is used so if no username was present, the applications title would be:

Welcome To MyApp

If the username in the register was "Jimbo" the applications title would be:

Welcome Jimbo

When using GetSettings you can't use it on its own. You must use as as part of an equasion such as

A = GetSettings

or

If GetSettings = a Then do b

etc. It simply supplies one piece of information from the registry just like a variable.

Learn about
Adding to the registry
Reading from the registry
Trapping Errors
Using Timers

Developer Sites
M World Developer
Javascript Now