Hello,
I need to make use of the registry or ini files in order to store basic user data.
I am using VB6, and I had problems fetching sample code about doing this.
Any help will be greatly appreciated.
Yours,
Vlad.
Printable View
Hello,
I need to make use of the registry or ini files in order to store basic user data.
I am using VB6, and I had problems fetching sample code about doing this.
Any help will be greatly appreciated.
Yours,
Vlad.
Reading and writing data to and from the registry is easy.
VB in fact uses HKEY_CURRENT_USER\SOFTWARE\VB AND VBA PROGRAM SETTINGS\app name
to store and retrieve data using savesetting and getsetting
VB Code:
Option Explicit Private Sub Command1_Click() 'create new registry settings SaveSetting "test reg app", "users\user1", "Name", "Paul" SaveSetting "test reg app", "users\user1", "Location", "Woolloomooloo" End Sub Private Sub Command2_Click() 'get at the registry settings MsgBox GetSetting("test reg app", "users\user1", "name") MsgBox GetSetting("test reg app", "users\user1", "location") End Sub Private Sub Command3_Click() 'Delete the registry settings 'DeleteSetting "test reg app", "users\user1", "name" 'delete a key DeleteSetting "test reg app", "users" 'delete beneath test reg app\users 'DeleteSetting "test reg app" 'delete all beneath test reg app End Sub This site has a few good tutorial on the registry too: [url]http://www.vb-world.com/registry/[/url]
Using registry:
VB Code:
dim opt_Username as string opt_Username="Eddie" SaveSetting "MyApp", "UserInfo", "Username", opt_Username opt_UserName=GetSetting("MyApp","UserInfo","Username","JohnDoe") msgbox "Now check your registry!"
I prever registry cuz no one bother missing with the registry...anyways, I added a molude that let's you use the registry...to add something to the registry, use the following code:
VB Code:
Private Sub Command1_Click() SaveSettingString HKEY_CURRENT_USER, "Software\App", "String Title", "String information" End Sub