ADVANCED Form Loaded Times

By | 2002-06-01

Gets how many times your form was loaded

Original Author: Demian Net

Returns

Returns as Long

Code

Public Sub SetLoaded()
  'put this in your main forms' Load procedure
  'this will set the count
  Dim lTemp As Long, sPath As String
  lTemp& = GetLoaded&
  If Right$(App.Path, 1) <> "" Then sPath$ = App.Path & "" & App.EXEName & ".tmp" Else sPath$ = App.Path & App.EXEName & ".tmp"
  Open sPath$ For Output As #1
  Print #1, lTemp& + 1
  Close #1
End Sub
Public Function GetLoaded() As Long
  'call this to get how many times program has been loaded
  On Error Resume Next
  Dim sPath As String, sTemp As String
  If Right$(App.Path, 1) <> "" Then sPath$ = App.Path & "" & App.EXEName & ".tmp" Else sPath$ = App.Path & App.EXEName & ".tmp"
  Open sPath$ For Input As #1
  sTemp$ = Input(LOF(1), #1)
  Close #1
  If sTemp$ = "" Then GetLoaded& = 0 Else GetLoaded& = CLng(sTemp$)
End Function

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.