Click to See Complete Forum and Search --> : SETTINGS


uni
March 30th, 2001, 07:48 AM
Does anyone know how to easily save the settings for each object on a form (either into registry or ini) so that if for eg. someone changes the background color it is stored.

As I need to save about 10 settings per object and I have up to 20 objects on a form and I may have 30 forms, saving each setting individually is not practical.

What l need is a module that allows me to simply send through the formname and have the module loop through all the settings on each form.

shree
March 30th, 2001, 08:43 AM
Use WriteProfileString and GetProfileString to read and write values to the registry.

Yes, you can write a function that takes a form as an argument as follows


public Sub SaveParams(aForm as Form)
dim aControl as Controls
for each aControl in aForm.Controls
'You can access the properties of the control using aControl.PropertyName
'And Concatenate them into a string
next
'Finally save the string using WriteProfileString here
End Sub

uni
March 30th, 2001, 08:20 PM
This is the problem, each control has different properties (or settings), so specifing each property for each control on every form would require 100's of lines of code. I need to be able to loop through the properties, not just the controls.

Thanks for your help.

shree
March 30th, 2001, 10:54 PM
Just use a superset of all properties, I mean, save all properties that you can think of, without concerning whether a control has it or not. It is sure that you'll get an error, but it doesn't matter, use an On Error Resume Next. It is a crude method however.