Changing Default Values at Runtime


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Changing Default Values at Runtime

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Posts
    46

    Changing Default Values at Runtime

    Hi, I'm just curious if it is at all possible to change the default values for any sort of component at runtime? What I mean is, for instance when you watch a DVD and you click 5.1 surround sound instead of stereo, the next time you start the DVD it remembers that you put it to 5.1 surround and you don't always have to keep changing it. Is there a way of doing something like this in VB6 without simply writing all default values to a file and reading them in when it is started?

    I'm mainly just trying to have a field where a user can select what part of the world they are in (to display the proper time), and if it is changed, the program remembers it next time it is used. Thanks!!

  2. #2
    Join Date
    Dec 2004
    Location
    México DF
    Posts
    127
    You can use SaveSetting to write to the registry, and GetSetting to retrieve from registry.

    HTH,

    mc

  3. #3
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    > ...without simply writing all default values to a file
    > and reading them in when it is started?

    How do you think the DVD player remembers its settings? ;-) If you want to remember a setting between executions of your app, you'll have to save them somewhere (e.g., file or registry).
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  4. #4
    Join Date
    Feb 2005
    Posts
    46
    Thanks! I will look into writing to the registry. I guess what I was more thinking was that when I add a component at design time, I can set a value for various things in the property field. No matter what I do in the code, the next time I run the application, that value is there first. I was wondering more if I could change that value at runtime.

  5. #5
    Join Date
    Dec 2004
    Location
    México DF
    Posts
    127
    Yes, you change the value at runtiem because you stored it in the registry (or an ini file)

    For instance, in my App I read the last accessed database:

    sBD = GetSetting(S_APP, "BD", "Origen", "")

    And when the user navigates to another MDB ans uses it, I save which was the file:

    SaveSetting S_APP, "BD", "Origen", sNewFile

    It's indeed simple. Only limitation is that,as far as I know, you can't choose where in the registry you write, it's always under VB applications or something similar.

    HTH,

    mc

  6. #6
    Join Date
    Nov 2003
    Location
    Sweden
    Posts
    74
    "Only limitation is that,as far as I know, you can't choose where in the registry you write, it's always under VB applications or something similar."
    That's not quite true. Using standard API's you can access and edit the registry at any position. And included in VB there's in fact a DLL called REGTOOL5.DLL, and when referenced (you find it at 'Registry Access Functions'), gives you a full set of functions to manipulate the registry. I don't know if it is free to redistribute, though.

    Bernie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center