VB - Using SaveSetting and GetSetting to store and retrieve data from the Registry

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

VB - Using SaveSetting and GetSetting to store and retrieve data from the Registry

SaveSetting stores the data in the Registry (in HKEY_CURRENT_USER|Software|VB and VBA Program Settings|YourAppName). The four parts of the function are the name under which it is stored (App.EXEName in this case), "textboxes" in this example is like the section name in an ini file, "text1" is like the key in a line of data in the ini file, and text1.text is the value.

GetSetting returns the value. The 4th parameter ("" in this case) is optional and it is the default if no registry entry is found.

Do not worry about your difficulties in Mathematics. I can assure you mine are still greater.

It depends on the size of the list. If it's a reasonably small list you could combine the data in a string separated by some unusual character and store it in one registry entry. Otherwise you should use a database or textfile to store the data.

Do not worry about your difficulties in Mathematics. I can assure you mine are still greater.

Have you ever tried saving to a registry in a Windows CE device.... i'm actually usine Embedded CE 3.0 which is very similar to vb6, but there are some differences.....i tried your code but it didn't recognize savesettings must be something similar with a ce device

SaveSetting stores the data in the Registry (in HKEY_CURRENT_USER|Software|VB and VBA Program Settings|YourAppName). The four parts of the function are the name under which it is stored (App.EXEName in this case), "textboxes" in this example is like the section name in an ini file, "text1" is like the key in a line of data in the ini file, and text1.text is the value.

GetSetting returns the value. The 4th parameter ("" in this case) is optional and it is the default if no registry entry is found.

Re: VB - Using SaveSetting and GetSetting to store and retrieve data from the Registry

I am trying to get the value of a checkbox that i have compiled in an exe.

This Function is in an activex component. It calls the form and checks the value that should be by default turned on in my exe. However, i seem to be having some trouble getting the value. Reading this post i thought the code below will give me the value of either 1 or 0 but that doesnt seem to be the case.

Public Function GetValue()

Dim AValue

AValue = GetSetting("TestSSvr", "checkboxes\frmdvan", "chkA", "")

GetValue = AValue

End Function

' I dont seem to be getting anything here
'Using this code AValue = GetSetting("TestSSvr", "checkboxes\frmdvan", "chkA", vbUnchecked) I get a 0 all the time????

'==========Here is the code that saves the value in my exe to the registry 'of the checkbox.This code works in loading the value from the registry and saving to it. But i dont seem to be able to get the value from my active x component when i call it(^Above)

Re: VB - Using SaveSetting and GetSetting to store and retrieve data from the Registry

will look in the Registry for HKEY_CURRENT_USER|Software|VB and VBA Program Settings|TestSSvr|checkboxes\frmdvan|frmdvan and if it doesn't find that entry it will return the string vbUnchecked because you have that value in quotes. If you aren't aware vbUnchecked is a built-in VB constant with a value of 0, so if you want to use it with your checkbox you should remove the quotes.

If that doesn't fix your problem you should use regedit and look for HKEY_CURRENT_USER|Software|VB and VBA Program Settings and see if it has a sub-folder named TestSSvr (and/or whatever your exe name is) and see what values are stored in that/those subfolders.

Do not worry about your difficulties in Mathematics. I can assure you mine are still greater.

End Sub--------------------------------------------------------------------------------

I use this code to get the checkboxes registry value when form loads from registry....
visual basic code:--------------------------------------------------------------------------------Private Sub Form_Load()

Re: VB - Using SaveSetting and GetSetting to store and retrieve data from the Registry

Have you ever looked inside the Registry? If not then do Start|Run|Regedit and you will see something that looks similar to Windows Explorer. One of the first "folders" will be HKEY_CURRENT_USER. One of it's "sub-folders" will be "Software", etc.

Do not worry about your difficulties in Mathematics. I can assure you mine are still greater.