CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2001
    Location
    Cambridgeshire, England
    Posts
    8

    date of last run

    Can anyone tell me how to call the date and time of the last time a vb5 exe has been run? What I have is an exe project that copies a file from one dir to another(this is how i am backing a project up) but what i want is to print on the form when it is opened the date and time that it was last run.

    Thanks in advance for any help in this matter

  2. #2
    Join Date
    Apr 2001
    Posts
    90

    Re: date of last run

    Wouldn't it just be the date of the file in the new directory? Is there a chance that "backup" could be written over by another application?

    CodeHacker
    Rate me if it helped, Thanks

  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: date of last run


    'what about writing and reading it in a small txt file (or in registry with
    'savesetting,...)?
    'ie:
    option Explicit

    private Sub Form_Load()
    Dim lastD
    If Dir("lstrun.txt") = "" then
    Open "lstRun.txt" for Output as #1
    print #1, date
    Close #1
    End If
    Open "lstRun.txt" for input as #1
    Line input #1, lastD
    Close #1
    me.Caption = lastD
    End Sub

    private Sub Form_Unload(Cancel as Integer)
    Open "lstRun.txt" for Output as #1
    print #1, date
    Close #1
    End Sub




    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  4. #4
    Join Date
    Aug 2001
    Location
    Cambridgeshire, England
    Posts
    8

    Re: date of last run

    i have tried to make it as simple as possible and all i want is to have the date and time that it was last run printed on the form so that i can see when it was last run when i open the program

    Thanks in advance for any help in this matter

  5. #5
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: date of last run

    Try this...


    private Sub Form_Load()
    me.Caption = GetSetting(App.Title, "Settings", "LastRun", "")
    End Sub

    private Sub Form_Unload(Cancel as Integer)
    SaveSetting App.Title, "Settings", "LastRun", Now()
    End Sub




    (You'll have to run it twice since the first time the time/date hasn't been saved yet.)


  6. #6
    Join Date
    Jan 2000
    Location
    Saskatchewan, Canada
    Posts
    595

    Re: date of last run

    The filesystemobject has a date last assessed property. Will that work? I know that it is not a date last run because this property will be updated if someone tried to open the exe with notepad etc., but it is as close as you're gonna get without using the procedures as already described in the previous posts.

    David Paulson


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

Featured