Page 2 of 2 FirstFirst 12
Results 41 to 51 of 51

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

  1. #41
    Addicted Member
    Join Date
    Mar 2006
    Posts
    226

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

    Quote Originally Posted by MartinLiss
    No, but you can use any one of several encryption/decryption methods to protect the data.
    may i ask if u can point me to these methods?

  2. #42

  3. #43
    Addicted Member
    Join Date
    Mar 2006
    Posts
    226

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

    like what should i search for? encryption ect...?

  4. #44

  5. #45
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

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

    Quote Originally Posted by MartinLiss
    encrypt or encryption would certainly seem to be good choices.
    heh, you're killing me over here.

    I'm confused by this whole thread. I thought the code base was for finished solutions. Why devote a thread to standard VB functions? It seems about as useful as devoting a thread to the InStr() function.

  6. #46

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

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

    You are thinking of the Utility Bank. The Code Bank is for useful snippets of code. If you want to continue this discussion please either post in Forum Feedback or PM me.

  7. #47
    New Member
    Join Date
    Jul 2007
    Posts
    2

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

    It seems to me that you are using different application names in GetSetting and SaveSetting functions-

    SaveSetting App.EXEName, "checkboxes\frmTestAdvanced", "chkAudit", chkAudit.Value

    and

    GetSetting("TestSummitSvr", "checkboxes\frmTestAdvanced", "chkAudit", vbUnchecked)

    I don't know the full logic of your program, but if this is true then you are not reading from the same location in regisrty as you are writing to, unless the App.EXEName is "TestSummitSvr"



    Quote Originally Posted by draven2kg
    The following code is in a class module in a dll :

    I have a dll that makes a call to get a checkboxes value from my registry.
    However i keep getting a 0 which i think is the default value or a vbUnchecked value. What am i doing wrong?




    visual basic code:--------------------------------------------------------------------------------Public Function GetAuditValue() As Variant

    Dim AValue As Variant


    AValue = GetSetting("TestSummitSvr", "checkboxes\frmTestAdvanced", "chkAudit", vbUnchecked)



    Dim fso2, txtfile2

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set txtfile = fso.OpenTextFile("C:\test\testfile2.txt", 8, True)

    txtfile.WriteLine AValue
    txtfile.Close



    GetAuditValue = AValue


    End Function--------------------------------------------------------------------------------



    This prints a 0 to my text file even though the key in my registry is a 1









    The codes below are in an exe on a form that has a check box that i have to save and get the settings from registry.




    visual basic code:--------------------------------------------------------------------------------Private Sub cbOK_Click()

    SaveSetting App.EXEName, "checkboxes\frmTestAdvanced", "chkAudit", chkAudit.Value

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




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

    chkAudit.Value = GetSetting(App.EXEName, "checkboxes\frmTestAdvanced", "chkAudit", vbUnchecked)

    End Sub

    --------------------------------------------------------------------------------

    Here is a slight change.

  8. #48
    Junior Member
    Join Date
    Apr 2007
    Posts
    30

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

    You can use this information for checkboxes too ...just use you'r mind...

    This is how i did it ...

    There is a TextBox called Text1 on my form and it is invisible ... and there is a checkbox and a timer (value = 10)

    And this is the code :

    Code:
    Private Sub Check1_Click()
    If Check1.Value = 0 Then Text1.Text = "UnChecked"
    If Check1.Value = 1 Then Text1.Text = "Checked"
    End Sub
    
    Private Sub Form_Load()
    Text1.Text = GetSetting(App.EXEName, "textboxes", "text1", "")
    
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
    SaveSetting App.EXEName, "textboxes", "text1", Text1.Text
    End Sub
    
    Private Sub Timer1_Timer()
    If Text1.Text = "Checked" Then Check1.Value = 1
    Timer1.Enabled = False
    End Sub


    P.S

    Anyone knowes how can i save the content of a listbox in registry ??

  9. #49

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

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

    Sure. Loop through the entries saving them to a string separated by something that's not likely to be in any of them like "||" and then write that string to the registry. When you want to restore them use Split on what GetSetting returns.

  10. #50
    Member
    Join Date
    Jan 2009
    Posts
    56

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

    Hi!

    This is really useful, thanks!

    My question is, how can i make if statement on loading that checks if this value is already saved?

    I want to do something like this


    If SOMETHING THAT CHECKS IF VALUE IS SAVED <> "" Then
    Command1.enabled = false
    Else
    End If

    Basicly i want to check that if value is already saved then disable save button...



    Regards

  11. #51

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

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

    As I mentioned in post#1, the 4th parameter of GetSetting is the default so you could do this.

    Code:
    If GetSetting(App.EXEName, "textboxes", "text1", "") <> "" Then
        Command1.enabled = false
    End If

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width