Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleDisplay the number of times a program has run and its last run time
Keywordsdisplay, times run, last time
CategoriesTips and Tricks, Windows
 
Save the number of runs and the last time in the registry with the GetSetting and SaveSetting statements.
 
Private RunTimes As Long
Private RunDate As Date

Private Sub Form_Load()
    RunTimes = GetSetting("CounterApp", "Counts", _
        "NumTimes", 0) + 1
    RunDate = GetSetting("CounterApp", "Counts", _
        "LastTime", Now)
    If RunTimes > 1 Then
        lblTimes.Caption = "This program has been run " & _
            Format$(RunTimes) & " times."
        lblDate.Caption = "The last was at " & _
            Format$(RunDate) & "."
    Else
        lblTimes.Caption = "This is the program's first " & _
            "run."
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    SaveSetting "CounterApp", "Counts", "NumTimes", RunTimes
    SaveSetting "CounterApp", "Counts", "LastTime", Now
End Sub
 
Formatted by Neil Crosby
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated