Results 1 to 6 of 6

Thread: [RESOLVED] [02/03] Saving data on close/terminate.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    115

    Resolved [RESOLVED] [02/03] Saving data on close/terminate.

    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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [02/03] Saving data on close/terminate.

    Handle the Closed event of your main form and save the data in the event handler.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    115

    Re: [02/03] Saving data on close/terminate.

    Quote Originally Posted by jmcilhinney
    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?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [02/03] Saving data on close/terminate.

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    115

    Re: [02/03] Saving data on close/terminate.

    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()?


    Thanks.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [02/03] Saving data on close/terminate.

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width