Simple way to store strings in the Registry

Level:
Level1

When I first started to learn how to program Windows applications I was mystified by the Windows Registry. I discovered that programs would store information there and most "normal" users would never even know about it. This was the perfect place to store encrypted passwords and things like that. Of course now days the registry is becoming less and less helpful because it has grown enormously and is a pain to move when a computer is upgraded. Still storing a value in the registry, especially program settings or things such as that, can be very helpful. This code snippet shows you how to use Visual Basic's built in SaveSetting and GetSetting commands to store and retrieve data in the registry.

To use this code create a new Visual Basic project, add two command buttons to it, add two text boxes. Go to the code area and add the following source code.

  1. Private Sub Command1_Click()
  2.         SaveSetting "MyString", "New", "Test", Text1.Text
  3. End Sub
  4.  
  5. Private Sub Command2_Click()
  6.         Text2.Text = GetSetting("MyString", "New", _
  7.                 "Test", vbNullString)
  8. End Sub
  9.  
  10. Private Sub Form_Load()
  11.         Text1.Text = "This is a Test"
  12.         Command1.Caption = "Write Value"
  13.         Command2.Caption = "Read Value"
  14. End Sub

After you have added the source, run your program and you should be able to save and retrieve data from the registry.

Note: The source for this was found at DreamVB which is no longer online.

If you enjoyed this post, subscribe for updates (it's free)

sample vb 6.0 auto search in database access

first make a database,name it as sample create a table in database(just right click and click new table) name the
table as tbl_sample
add adodc or microsoft ado data controll
add a module
add 1 textbox in the form 1 and 1 command button
right click adodc1 click adodc properties and then
click build then browse then find the database named "sample" then click
test the connection and if test connection has been succeed then click ok
copy all of the text in adodc and click cancel

if you are done do this code...

'call---means call a subroutine in module's

'click the module's and put this code

public rs as new recordset
public con as new connection
public com as new command

public sub mycon()
set rs = new recordset
set con = new connection
set com = new command

'put the connection of adodc to the connectionstring
con.connectionstring = "paste the text that you've been copied inside this Qoutation marks"
con.open
com.activeconnection = con
end sub

if you are done put this code in the command button in the form1

set rs = new recordset
rs.open "Select * from (database tbl) where("fields") example of fields name = '" & (object) & "'",con,1,2
'whole sample
rs.open "Select * from tbl_sample where name = '" & text1.text & "'",con,1,2
if rs.eof then ----------meaning "if recordset not found the text in text1.text then"
if rs.eof then
rs.addnew
rs!name = text1.text
rs.update
else
msgbox "this name is exist in your database
end if
set rs = nothing

put this code in command button
whole example

public sub command1_click ()
call mycon
set rs = new recordset
rs.open "Select * from tbl_sample where name = '" & text1.text & "'",con,1,2
if rs.eof then
rs.addnew
rs!name = text1.text
rs.update
else
msgbox "this name is exist in your database",vbexlamation + vbokonly,"SAMPLE"
end if
set rs = nothing

end sub

if you are done just annalyze this code for some info
thankyou :)

Private Sub

Private Sub cmdsave_Click()

Set rs = New ADODB.Recordset
rs.Open "select * from table1", cn, adOpenKeyset, adLockOptimistic
rs.AddNew
rs!id = txtid.Text
rs!Name = txtname.Text
rs!age = txtage.Text
rs!address = txtaddress.Text
rs!profile = txtprofile.Text
rs.Update
MsgBox "Saved!"
Form1.clear
rs.Close
Set rs = Nothing

End Sub

help

how to save text in vb6
i use adodc1.recordset.save and
it just clear the text in the text area

How to create a colored

How to create a colored message box in vb6.0

Useful in everyday programming!

This is what I'm looking for my system to work without any database to store my system settings.. Thank you for this very useful information.. ^_^

Mayo akong maginibo

Mayo akong maginibo

Database

please i need to connect the access 2003 to vb6 i need some help.

Thanks

Is your concern already

Is your concern already answered?
if not...

SAMPLE:

Private Sub cmdsave_Click()

Set rs = New ADODB.Recordset
rs.Open "select * from table1", cn, adOpenKeyset, adLockOptimistic
rs.AddNew
rs!id = txtid.Text
rs!Name = txtname.Text
rs!age = txtage.Text
rs!address = txtaddress.Text
rs!profile = txtprofile.Text
rs.Update
MsgBox "Saved!"
Form1.clear
rs.Close
Set rs = Nothing

End Sub

Cool!

Now I can Copy and Paste, AND store and retrieve data from the registry at the same time!!!

Logic to make fully secured CD

Dear Friends,

Can any body help to produce a below type CD using VB6 ?. I have seen Some Educational CDs like this.

In that CD, there are following properties.

1. In the very first run of that CD on a particular PC, an interface appear and it displays a code from the program it self and another Blank text box asking a pin number.
2. Then We have to call to the CD dealer and get the PIN number from them and enter to that blank text box.
3. This step never occur after that.
3. After that the tutorials start to run with exercises.
4. The CD should always be in the CD driver to watch the animated lessons and to do the activities/exercises in it.
5. If we try to run this CD in another PC, again the interface called in step 1 appear and if we call to the CD dealer to get a PIN number they knows that a PIN number for that particular CD is already given and they will not give a PIN number.
6. The Original PIN number does not work with the new PC.
7. Can any body think of a way to do this using VB6 and if so please be kind enough to share with.

Thanks&Regards
Ruwan