user445714
user445714

Reputation: 393

Disabling a button and saving it after a restart

Just doing a bit of self teaching on visual basic, I have a list of buttons and when clicked I want to disable then and highlight them as red. I am ok on getting the button functions to work and I understand how to publish the gui as an .exe

Is it possible to save it so if i click on the button and it turns red and then i close the .exe and open it again the button stays red?

Upvotes: 0

Views: 95

Answers (2)

paulsm4
paulsm4

Reputation: 121629

You're asking three questions here; I'm not sure which ones you still need answered. At the risk of repeating what you already know:

1) To disable a button, set "enabled = false"

2) To change the color of a button, set "color = red"

... and ...

3) To "persist" an .exe's state when you run it, you'll need to 1) save the current state (for example, to a text file, an .ini file, or an .XML file). 2) You'll need to re-read that state when you open the program (e.g. in "Load form"). 3) It would be best to write the file would be all current settings at once, when you exit (e.g. in "Unload form").

Upvotes: 4

drdwilcox
drdwilcox

Reputation: 3951

You will have to store the setting somewhere permanent. On Windows, the preferred place is in the registry. Here is Microsoft's introduction to the topic: http://msdn.microsoft.com/en-us/library/aa289494%28v=vs.71%29.aspx

You could save settings elsewhere, but directory permissions make it tricky to find a good place.

What you cannot safely do it modify your program.

Upvotes: 0

Related Questions