I want to call a function that saves data to a text file when my app is closed or terminated. How do I do this?
Please note I am using 2002 version.
Thanks.
Printable View
I want to call a function that saves data to a text file when my app is closed or terminated. How do I do this?
Please note I am using 2002 version.
Thanks.
Handle the Closed event of your main form and save the data in the event handler.
sorry but im a bit of a newbie... how do i do that?Quote:
Originally Posted by jmcilhinney
To create an event handler you open the code window, select the object from the drop-down list at the top left and the event you want to handle from the drop-down list at the top right. To write text to a file you use a StreamReader object.
I know how to save the data. In the drop down their is a finalize event - is that the one where I should add my code before the MyBase.Finalize()?Quote:
Originally Posted by jmcilhinney
Thanks.
Finalize is not an event. It's a method. You should absolutely NOT be saving settings in the Finalize method. I've already said that you should be doing it in the Closed event handler.