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 as follows.
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 the example below.
A = GetSettings
You can also do the following.
If GetSettings = a Then do b
It simply supplies one piece of information from the Registry just like a variable.
Don't have time to check my blog? Get a weekly email with all the new posts. This is my personal blog, so obviously it is 100% spam free.
Tags: data, registry, vb, visual basic
This entry was posted on Thursday, December 30th, 2004 at 4:07 pm and is filed under Programming, Tech. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.