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!!
You can use SaveSetting to write to the registry, and GetSetting to retrieve from registry.
> ...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).
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
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.
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.
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.
"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."
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL