AuthorMessage
C0D3Z3R0
Pro
Posts: 166

Does anyone know how I could save settings to a file or to the registry? I'm making a backup program to backup a few files every few hours but I want it to be saved on how many hours before the next backup, thanks in advance
bluebear
n00b
Posts: 32

registry:
write reg:
Syntax: SaveSetting appname, section, key, setting
Example: SaveSetting App.EXEName, "Options", "StayOnTop", chkOnTop.value
Read reg:
Syntax: GetSetting(appname, section, key[, default]
Example: GetSetting(App.EXEName, "Options", "StayOnTop", 0)
default (last arg) is returned if the key do not exist!
C0D3Z3R0
Pro
Posts: 166

thanks now to figure out how to use it
bluebear
n00b
Posts: 32

Quoted from C0D3Z3R0
thanks now to figure out how to use it

K.
Code:
Dim setting1 As String
Dim setting2 As String
Private Sub Form_Load()
  ' Put data into 2 variables
  setting1 = "ThisIsARegstryTest"
  setting2 = "ThisIsAnotherTest"
 
  ' Save the data from those variables in registry
  SaveSetting App.EXEName, "Options", "setting1", setting1
  SaveSetting App.EXEName, "Options", "setting2", setting2
 
  ' Now they are stored in regstry, empty the variables
  setting1 = setting2 = ""
 
  'Now we load the 2 settings from regstry
  setting1 = GetSetting(App.EXEName, "Options", "setting1", "DefaultResponse")
  setting2 = GetSetting(App.EXEName, "Options", "setting2", "DefaultResponse")
 
  'Display in messagebox
  MsgBox ("Data from setting1: " & setting1)
  MsgBox ("Data from setting2: " & setting2)
 
  'For fun we try to load a setting that do not exist.
  Dim setting3 As String
  setting3 = GetSetting(App.EXEName, "Options", "setting3", "DefaultResponse")
  ' Display in msgbox
  MsgBox ("Data from setting3: " & setting3)
End Sub

bluebear
n00b
Posts: 32

After running the test code, open regstry editor and search for "ThisIsARegstryTest" then you'll find the place in regstry where the data is stored!
C0D3Z3R0
Pro
Posts: 166

thanks, now i know how to do it
Meka][Meka
Unstopable
Posts: 700

if you want to use a INI file, u can optionally do the easy way and use MekaDLL, which has its own ini module, its as easy as
Code:

    Dim s As String
   
    Call OpenINI(".\test.ini")
    Call INIWrite("LOL", "LOL", "testttttter")
    s = INIRead("LOL", "LOL", "tesst")
    Call CloseINI
   
    MsgBox s

check the components section of the forums, and u will see thread 'VB MekaDLL Component' download it and it has the wrapper included...
b_w_johan
Regular
Posts: 56

Hey meka,
i think there is a small bug in that writing to ini
ive created a small program wich counts how many times you clicked something.
so click on button 1 writes down:
[username]
button1=1
so far so good hehe
when i click second time on (same orother) button it crashes and gives that error i discribed to you already about unable to wright disk protected/full
so i reopen the program click on button 2 and ini looks like
[username]
button1=1
button2=1
and i click on another button and crash
its same with clicking button 1 then it counts up hehe but i can only do 1 writing action per time i start the aplication
any idea's ???
Meka][Meka
Unstopable
Posts: 700

i checked all sorts of ways and it works just fine, maybe something u r not doing correct, wait til i write a 'README' file for the component.
b_w_johan
Regular
Posts: 56

Private Sub Command4_Click()
    knop1.Text = knop1.Text + 1
    Call OpenINI(".\Resultaten.ini")
    Call INIWrite(Text1.Text, "ADSL Service", knop1.Text)
    Call CloseINI
End Sub
Private Sub Command5_Click()
    knop2.Text = knop2.Text + 1
    Call OpenINI(".\Resultaten.ini")
    Call INIWrite(Text1.Text, "ADSL Levering", knop2.Text)
    Call CloseINI
End Sub
thats what ive used.....
Text1.Text = name of user
but rhis works
but well only one time second time i push a button an error ocures and crashes the program
Johan
(hoping to see the readme soon so this gets to work hehe)