The easiest way to do this, is to have a settings file (you could use the registry also, but I find files are easier to clean up, and fit logical structure a lot better). In your settings file, you have 1 line per text box (or default value). This way, line 1 of the file will always be the default value for text1. Line 2 for text2, etc, etc. Then, on form load (or sub main, or whatever), just open the file for input, read it in, and set the values accordingly. This is how I do it. I actually have a sub that I call on startup, that makes sure everything is set before it actually loads. I just callt he sub in form_load, and it makes sure I have directories (should I need them), and if I have settings it loads the settings....
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
Just a plain text file.... something lto write the file ike:
open app.path & "\settings.dat" for output as #1
print #1, text1.text
print #1, text2.text
close #1
and read it like:
if dir(app.path & "\settings.dat", vbnormal) <> "" then
open app.path & "\settings.dat" for input as #1
line input #1, text1.text
line input #1, text2.text
close #1
end if
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
As a person who is diligent in the open source community, even programs that are NOT open source, should still have the availibility to have the settings altered fairly easily. That's one reason I've hated proprietary software, is because it's on my computer, I should be able to mess with it as I please..... If I want to change the settings with Notepad, or DOS Edit instead of some gui that someone has decided was the best interface, I should have the option and that right, and that should be made fairly easily to access. Granted, you could use regedit to "manually" alter settings, but it's the principle of the idea behind it. Plus, there isn't really that many more steps needed.... on form unload, simply do an open for output (which overwrites previous values) and on form_load read the input into the correct textboxes.... but either way you choose to do it, I wish you the best of luck.
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
No. You are absolutely correct. I tried to do it that way also (skipping variables) and it gets pretty upset. I guess it's just the name of the game, and I appreciate your return response.
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215