views:

114

answers:

2

how do you save the value of a variable for later if the application is closed and reopened in winforms, vb.net?

+1  A: 

yes by using cookies.

Response.Cookies("userName").Value = "yourvalue"
Response.Cookies("userName").Expires = DateTime.Now.AddDays(2)

But the cookie must be created on that machine

Eric
in a windows application not in the browser
I__
i don't think it matters...as long as the cookie is created on the machine the windows form will try to access it on.
Eric
wow very interesting. i didnt know this.
I__
did it work for you?
Eric
+5  A: 

Yes. Just save it in the Application Settings.

Reed Copsey
cool. didn't know that.
Eric
this is a great tutorial. however it is not working for me. Form1.BackColor = ColorDialog1.Color My.Settings.last_color = Form1.BackColor
I__
You need to add the setting explicitly, either on the form or project. See: http://msdn.microsoft.com/en-us/library/25zf0ze8.aspx
Reed Copsey
do i have to call something onload?
I__