Results 1 to 22 of 22

Thread: Saving settings in VB programs.

Hybrid View

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    5

    Saving settings in VB programs.

    Can someone give me some advice on coding a VB program so that values can be saved, and reappear when the program is reopened? This would also apply to coding a program so that you can set default values so the user can customize the application.

  2. #2
    Lively Member trip85's Avatar
    Join Date
    Jun 2000
    Location
    Chalfont, PA
    Posts
    106

    Re: Saving settings in VB programs.

    You can use the Windows registry. Look into SaveSetting and GetSetting in the MSDN dcumentation.
    Thanks in Advance!
    TRIP85

    In the game of life, it's not whether you win or lose, it's how drunk you get.
    -Homer Simpson

  3. #3
    Lively Member trip85's Avatar
    Join Date
    Jun 2000
    Location
    Chalfont, PA
    Posts
    106

    Re: Saving settings in VB programs.

    You can use the Windows registry. Look into SaveSetting and GetSetting in the MSDN dcumentation.

    GetSetting Function

    Returns a key setting value from an application's entry in the Windowsregistry.

    Syntax

    GetSetting(appname, section, key[, default])

    The GetSetting function syntax has thesenamed arguments:

    Part Description
    appname Required.String expression containing the name of the application or project whose key setting is requested.
    section Required. String expression containing the name of the section where the key setting is found.
    key Required. String expression containing the name of the key setting to return.
    default Optional.Expression containing the value to return if no value is set in the key setting. If omitted, default is assumed to be a zero-length string ("").

    Remarks

    If any of the items named in the GetSetting arguments do not exist, GetSetting returns the value of default.



    SaveSetting Statement


    Saves or creates an application entry in the application's entry in the Windowsregistry.

    Syntax

    SaveSetting appname, section, key, setting

    The SaveSetting statement syntax has thesenamed arguments:

    Part Description
    appname Required.String expression containing the name of the application orproject to which the setting applies.
    section Required. String expression containing the name of the section where the key setting is being saved.
    key Required. String expression containing the name of the key setting being saved.
    setting Required.Expression containing the value that key is being set to.


    Remarks

    An error occurs if the key setting can’t be saved for any reason
    Thanks in Advance!
    TRIP85

    In the game of life, it's not whether you win or lose, it's how drunk you get.
    -Homer Simpson

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    5

    Re: Saving settings in VB programs.

    Thanks, Trip85. I did try the GetSetting and SaveSetting once and I couldn't get it to work. I'll give it another look over and see if I can find where I made the mistake.

  5. #5
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Saving settings in VB programs.

    Xml could be better path..

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Saving settings in VB programs.

    I just use a few text files in the app.path. They aren't .txt, but that's so others can't open them. It's much easier than using a database.

  7. #7
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Utah
    Posts
    397

    Re: Saving settings in VB programs.

    You might find these functions useful if you want to use a ini file to save settings.

    I got it somewhere on these forums but can't remember who wrote it.
    Attached Files Attached Files

  8. #8
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: Saving settings in VB programs.

    Quote Originally Posted by Narfy
    You might find these functions useful if you want to use a ini file to save settings.

    I got it somewhere on these forums but can't remember who wrote it.
    Cheers Narfy, I've been looking for this for a while
    thanks.
    Zeegnahtuer?

  9. #9

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