Can someone explain to me (in-depth), how to save settings like the backcolor and forecolor of a picture box.
Printable View
Can someone explain to me (in-depth), how to save settings like the backcolor and forecolor of a picture box.
You can save setting by using Savesetting function.
savesetting app.path,"Settings","backcolor",form1.backcolor
in this example setting is a registry section and backcolor is the registry key and form1.backcolor is the setting you want to save.
To get the setting back from the registry:
private sub form1_load()
on error resume next
dim Color
color = getsetting(app.path,"settings","backcolor",vbblack)
me.backcolor = color
end sub
in this example you have to give the same address as you gave the savesetting so the program can find the correct value. Then the program will store the value into color variable. And then assign the color variable value to the form backcolor.
What is the purpose of (On error resume next)?
well first you start the program you havn't saved anything in the registry therefore program can not return any value and you will get an error message, so you put the on error resume next on top to avoid this.
I tried that and it saves but not the colors i told it to save and the things i dont want to change color, change color. What now?